Prevent Activity From Restarting On Phone Boot?
Solution 1:
The ACTION_SHUTDOWN
broadcast is supposed to go out when the device is shutting down. I say "supposed to go out", because it assumes an orderly shutdown. If the user winds up holding the POWER button for ~10 seconds, or popping out the battery, I would assume that ACTION_SHUTDOWN
is not broadcast.
To control whether a component (e.g., activity) is available, you can use PackageManager
and setComponentEnabledSetting()
. A disabled component cannot be run and is generally invisible (e.g., a disabled app widget's <receiver>
will not show up in the app widget picker).
In theory, you can combine these two. However, even at the best of times, I would assume that ACTION_SHUTDOWN
behaviors are rather time-limited (so be quick about it), and you will need to handle the "disorderly" shutdown scenarios.
Post a Comment for "Prevent Activity From Restarting On Phone Boot?"