I want to know if there is a provision/solution to handle shutdown/unexpected shut down of android phone when the app is being used by the user.
One possible solution seems to be register a broadcast receiver for BATTERY_LOW. Are there any other good and effective solutions?
Your Broadcastreceiver...
public class ShutdownReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
//handle your stuff
}
}
and finally your manifest..
<uses-permission android:name="android.permission.DEVICE_POWER" />
<receiver android:name=".ShutdownReceiver">
<intent-filter>
<action android:name="android.intent.action.ACTION_SHUTDOWN" />
</intent-filter>
</receiver>
for some devices this is also required
android.intent.action.QUICKBOOT_POWEROFF