简体   繁体   English

我如何在Android中监听SD卡安装?

[英]How can I listen for SD card mounting in android?

I have a program that uses the SD card, so I want to be informed if the state of the card changes by registering a listener if possible. 我有一个使用SD卡的程序,所以如果可能的话,我希望通过注册听众来通知卡的状态是否发生变化。 I'm aware of the Environment class and its methods, but I don't really want to be constantly polling the state. 我知道Environment类及其方法,但我真的不想经常轮询状态。 I'd rather not have my program force close when running cause someone mounted the sd card to their computer. 我宁愿不让我的程序强制关闭,因为有人将SD卡安装到他们的计算机上。

ACTION_MEDIA_MOUNTED和相关意图创建BroadcastReceiver

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM