How can I listen for SD card mounting in android?
Question
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. I'm aware of the Environment class and its methods, but I don't really want to be constantly polling the state. I'd rather not have my program force close when running cause someone mounted the sd card to their computer.
Solution
Create a BroadcastReceiver for ACTION_MEDIA_MOUNTED and related intents.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow