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

查看:19
本文介绍了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?

推荐答案

首先,为了让您可以使用 Android 设备与其他设备进行通信,您必须使用 OTG 电缆或适配器,已经预先设置设备使其处于通信模式,并且已经为 Android USB api 提供了这和你没有必要操纵它,因为自动的变化

First of all, so that you can communicate with with other devices with your Android device you have to use an OTG cable or adapter, which already predisposes the device so that it is in communication mode, also the Android USB api is already provided for this and you you have no need to manipulate this because the change of automatic

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

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