I'm using a Samsung Galaxy S3,and connecting to a sensor using USB host and
a OTG cable. I'm at the beginning phase just trying to write code to detect
the sensor was attached but it's not working. Can someone take a look and
tell me what they think:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_microstrain);
find_device = (EditText)findViewById(R.id.find_device);
UsbManager manager = (UsbManager)getSystemService(Context.USB_SERVICE);
//connect();
HashMap<String, UsbDevice> deviceList = manager.getDeviceList();
Iterator<UsbDevice> deviceIterator = deviceList.values().iterator();
while(deviceIterator.hasNext()){
UsbDevice device = deviceIterator.next();
Toast.makeText(this,"Value of device :"
+device.getDeviceName(), Toast.LENGTH_LONG).show();
}
%%%%%% manifest %%%%%%%%%%%%%%%
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.microstrain"
android:versionCode="1"
android:versionName="1.0"
android:orientation="vertical">
<uses-feature android:name="android.hardware.usb.host"/>
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.microstrain.MICROSTRAIN"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"/>
</intent-filter>
<meta-data
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/device_filter" />
</activity>
<uses-library android:name="android.test.runner" />
</application>
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.example.microstrain"
android:label="microstrain" />
</manifest>
%%%%%%%%% xml/device_filter.xml %%%%%%%%%
<resources>
<usb-device vendor-id="199b" product-id="3d65"/>
</resources>
%%%%%%
I appreciate all the help. Thanks in advance!
--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.