Android USB API:在收费和数据发送之间切换 [英] Android USB API: Switch between charge and data send

查看:116
本文介绍了Android USB API:在收费和数据发送之间切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用Android USB API将数据从Arduino发送到Android设备.是否可以通过编程方式在发送/接收数据之间切换并仅为Android手机充电?

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?

我知道您不能同时执行两项操作,并且由于必须打开FileInputStream才能接收数据,因此只要打开该设备就不会收费.

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.

就像关闭该流以再次收费一样简单吗?如果就这么简单,那么Arduino可以发送基本信息以要求设备再次打开流吗?

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?

推荐答案

我不确定,我是否理解您的关注.要同时通过USB充电和通信,可以使用OTG.这是我分享的来自亚马逊的链接: https://www .amazon.com/Micro-Cable-Samsung-Player-OTHERS/dp/B00CXAC1ZW 我在我的一个项目中使用了它,它起作用了.

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.

这篇关于Android USB API:在收费和数据发送之间切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆