Cannot read serial data using USB Host
- By saramarz
- Android Development
- 1 Replies
hi casjkent2
you could try is to make sure that you have the necessary permissions to access the device. You can do this by adding the following code before you start the transfer thread:
You will also need to register a broadcast receiver to handle the permission request response. You can do this by adding the following code to the onCreate method of your activity:
Make sure that you have added the necessary permissions to your app's manifest file:
you could try is to make sure that you have the necessary permissions to access the device. You can do this by adding the following code before you start the transfer thread:
Code:
UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);
PendingIntent mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0);
manager.requestPermission(device, mPermissionIntent);
You will also need to register a broadcast receiver to handle the permission request response. You can do this by adding the following code to the onCreate method of your activity:
Code:
IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
registerReceiver(usbReceiver, filter);
Make sure that you have added the necessary permissions to your app's manifest file:
Code:
<uses-permission android:name="android.permission.USB_PERMISSION" />
<uses-permission android:name="android.permission.USB_HOST" />