How to implement Android Open Accessory mode as a service?

岁酱吖の 提交于 2019-12-03 03:51:36

The solution was simple.

if (intent.getAction().equals(USB_ACCESSORY_ATTACHED)) {
    Intent i = new Intent(this, YourServiceName.class);
    i.putExtras(intent);
    startService(i);
}

Basically, copy the intent that you received when starting your activity that you use to launch the service, because the intent contains the details of the accessory that the ADK implementation needs.

Then, in the service proceed to implement the rest of ADK exactly as before.

Sascha Waser

At the moment I can't give you a matching solution to your problem. But may be this github example shows you how to solve your problem:

I am going to analyse the code given on github to implement just the same thing you're going to do.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!