Android External App Install (on SD card), reset alarm alarms when re-mounting through receiver

I am developing an Android application that I want to allow users to install on their SD card (http://developer.android.com/guide/appendix/install-location.html). However, the application has some alarms created through AlarmManager. According to the Android developer’s guide (the link I included), if the external media (SD card) on which the application is installed is disabled, the following will happen: "Your alarms registered in AlarmManager will be canceled. Re-registration of any alarms when rebooting external storage. "

Is there any way to “wake up” my application so that I can redistribute the alarms when reinstalling the SD card? Maybe use a receiver with some intent filter? I tried to add a receiver for android.intent.action.MEDIA_MOUNTED, but this did not work (perhaps because applications installed externally do not receive translation of this intention or because application binaries are not available immediately after installing the media and that intent is being broadcast?). Any other intentions anyone can suggest? Or some other way to do this? Android .intent.action.EXTERNAL_APPLICATIONS_AVAILABLE intentions (http://developer.android.com/reference/android/content/Intent.html#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE) is similar to what I need, but the documents say that the applications on external media will not receive of this intention.

+6
source share
2 answers

There is currently no workaround for this: either force the application to be installed only in the internal memory, or implement an additional application that is stored in the internal memory and processes your alarms.

0
source

I do not think this is possible, see What does not work on the SD card. It seems rather lame, but without a service without an SDK to monitor mount / unmount conditions, which would also be a bit lame, this is not possible.

Another reason not to place the main application on the SD card, the USB cable can also cause the storage to be disconnected, etc., if the user connects to the hard drive on the PC.

0
source

Source: https://habr.com/ru/post/892620/


All Articles