概述
我能够通过
Android的USB Host API获得与设备通信的权限.
private static final String ACTION_USB_PERMISSION = "com.android.example.USB_PERMISSION";
protected void execute(Context ctxt) {
UsbManager manager = (UsbManager) viewer.getSystemService(Context.USB_SERVICE);
HashMap deviceList = manager.getDeviceList();
UsbDevice d = null;
for (String s : deviceList.keySet()) {
d = deviceList.get(s);
}
PendingIntent mPermissionIntent = PendingIntent.getBroadcast(ctxt, 0, new Intent(ACTION_USB_PERMISSION), 0);
IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
viewer.registerReceiver(mUsbReceiver, filter);
manager.requestPermission(d, mPermissionIntent);
}
private final BroadcastReceiver mUsbReceiver = new BroadcastReceiver() {
public void onReceive(Context context
最后
以上就是轻松茉莉为你收集整理的android动态权限usb,通过android.hardware.usb获得的USB权限不适用于NDK的全部内容,希望文章能够帮你解决android动态权限usb,通过android.hardware.usb获得的USB权限不适用于NDK所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复