编程关闭Android设备上的USB存储器 [英] Programmatically Turn Off USB Storage on Android Devices

查看:223
本文介绍了编程关闭Android设备上的USB存储器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在许多Android设备,在设备插入电脑,甚至在某些USB设备充电的USB接口,手机进入USB存储模式。当设备处于这种模式下,Android应用程序无法访问SD卡。有什么办法(1)来检测时,该设备在此模式下,(2)以编程方式关闭USB存储设备,至少是暂时的,所以我的Andr​​oid应用程序可以访问SD卡?

On many android devices, when the device is plugged into the USB port of a computer or even on some USB charging devices, the phone goes into USB Storage mode. When the device is in this mode, android apps cannot access the sdcard. Is there any way (1) to detect when the device is in this mode and (2) to programmatically turn off USB storage, at least temporarily, so my android app can access the sdcard?

我见过的其他SO问题和答案是不是真的足够 (例如,安卓检测USB )。

I've seen other SO questions and the answers are not really sufficient (e.g., Android: Detecting USB).

推荐答案

您可以检测到它(你有链接),但是,AFAIK,你不能挂载/卸载USB存储至少不与公众SDK的API。在蜂窝(3.0及以上),USB大容量存储不再用于访问设备的外部存储,让您的应用程序,一台电脑可以同时访问它。

You can detect it (you have the link), but, AFAIK, you can't mount/unmount USB storage at least not with the public SDK APIs. In Honeycomb (3.0 and above), USB mass storage is no longer used to access the device's external storage, so your app and a computer can access it simultaneously.

这篇关于编程关闭Android设备上的USB存储器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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