我是靠谱客的博主 会撒娇猎豹,最近开发中收集的这篇文章主要介绍android aoa usb,建立通过USB连接线使用AOA protocal两款Android设备,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

您是否通过意图请求许可来查看附件?

您是定义自己的自定义类型和通信层还是试图通过adb ....这样做?更多信息可能会很好。但现在,您需要知道您是否可以看到该设备。

private void checkInfo() {

manager = (UsbManager) getSystemService(Context.USB_SERVICE);

/*

* this block required if you need to communicate to USB devices it's

* take permission to device

* if you want than you can set this to which device you want to communicate

*/

// ------------------------------------------------------------------

mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(

ACTION_USB_PERMISSION), 0);

IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);

registerReceiver(mUsbReceiver, filter);

// -------------------------------------------------------------------

HashMap deviceList = manager.getDeviceList();

Iterator deviceIterator = deviceList.values().iterator();

String i = "";

while (deviceIterator.hasNext()) {

device = deviceIterator.next();

manager.requestPermission(device, mPermissionIntent);

i += "n" + "DeviceID: " + device.getDeviceId() + "n"

+ "DeviceName: " + device.getDeviceName() + "n"

+ "DeviceClass: " + device.getDeviceClass() + " - "

+ "DeviceSubClass: " + device.getDeviceSubclass() + "n"

+ "VendorID: " + device.getVendorId() + "n"

+ "ProductID: " + device.getProductId() + "n";

}

textInfo.setText(i);

}

private final BroadcastReceiver mUsbReceiver = new BroadcastReceiver() {

public void onReceive(Context context, Intent intent) {

String action = intent.getAction();

if (ACTION_USB_PERMISSION.equals(action)) {

synchronized (this) {

UsbDevice device = (UsbDevice) intent

.getParcelableExtra(UsbManager.EXTRA_DEVICE);

if (intent.getBooleanExtra(

UsbManager.EXTRA_PERMISSION_GRANTED, false)) {

if (device != null) {

// call method to set up device communication

}

} else {

Log.d("ERROR", "permission denied for device " + device);

}

}

}

}

}; :

https://source.android.com/devices/accessories/aoa2.html

文本从复制

最后

以上就是会撒娇猎豹为你收集整理的android aoa usb,建立通过USB连接线使用AOA protocal两款Android设备的全部内容,希望文章能够帮你解决android aoa usb,建立通过USB连接线使用AOA protocal两款Android设备所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(41)

评论列表共有 0 条评论

立即
投稿
返回
顶部