Android USB API: Switch between charge and data send

醉酒当歌 提交于 2019-12-22 04:43:20

问题


I'm starting to use the Android USB API to send data from an Arduino to an Android device. Is it possible to programmatically switch between send/receive data and just charge the Android phone?

I know that you cannot do both things at the same time, and, since you have to open a FileInputStream in order to be able to receive data, as long as this is open the device won't be charged.

Will it be just as simple as closing this stream to charge again? If is as simple as it, can the Arduino then send basic information in order to ask the device to open the stream again?


回答1:


I am not sure, I understand your concern or not. To charge and communicate through USB at the same time, you can use OTG. Here is link from Amazon, I shared: https://www.amazon.com/Micro-Cable-Samsung-Player-OTHERS/dp/B00CXAC1ZW I used it in one of my projects, it works.



来源:https://stackoverflow.com/questions/13200334/android-usb-api-switch-between-charge-and-data-send

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