开发者

Android External App Install (on SD card), reload alarmmanager alarms on re-mount through receiver

I'm developing an android app that I want to allow users to install on their SD card (http://developer.android.com/guide/appendix/install-location.html). However, the app has some Alarms created through AlarmManager. According to the android developers guide (the link I've included), if the external media (SD card) that the app is installed on is unmounted, the following will happen: "Your alarms registered with AlarmManager will be cancelled. You must manually re-register any alarms when external storage is remounted."

Is there some way I can "wake" my app up so that I can re-schedule the alarms when the SD card is remounted? Maybe use a receiver with some intent filter? I tried adding a receiver for android.intent.action.MEDIA_MOUNTED, but that didn't work (maybe because apps installed externally don't get that intent broadcast, or because the app binaries aren't available immediately after media is mounted and that intent is broadcasted?). Any other intents someone can suggest? Or some other way to do this? The android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE intent (http://developer.android.com/reference/android/content/Intent.html#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE) seems like what I'd need, but the docs say the apps on the external media will开发者_高级运维 not get this intent.


Currently no workaround for this: either force your app to only be installable on internal memory or implement an add-on application that stays in internal memory and handles your alarms.


Don't think this is possible see What doesn't work on a sdcard This seems pretty lame but without a non-sdcard service to monitor mount/unmount conditions, which would also be kind of lame, it does not seem possible.

Yet another reason not to put the main app on the sdcard, usb cable can also cause the storage to unmount etc. if the user connects as a hard drive to a pc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜