6

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.

AdeelMufti
  • 341
  • 1
  • 8

2 Answers2

0

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.

Femi
  • 64,273
  • 8
  • 118
  • 148
  • What's an add-on application? Can you execute one without the need of a user to download it from the market? – AlikElzin-kilaka Sep 21 '11 at 14:12
  • Basically a second, independent APK that is internal-memory only but works with the first one. My use of the term *add-on application* isn't intended to be a standard form, just a general adjective describing the way it would be used. Perhaps *companion* would be a better adjective. And no, you can't execute it without the user having to download/install from the market. – Femi Sep 21 '11 at 14:17
  • 1
    @Femi So it's almost 10 years after you answered above. Is there any way these days to reset Alarms after a device reboot with the app installed on external storage? If not, then your answer still holds that the app must be installed on internal memory? – AJW Mar 31 '21 at 18:48
0

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.

Community
  • 1
  • 1
Idistic
  • 6,281
  • 2
  • 28
  • 38