Detecting shut down and reboot in android
Hi, Have a great day frnds.. Now we going to look up the detecting shut down and reboot events in android. Here is the code: import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.util.Log; public class ShutDownReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(Intent.ACTION_SHUTDOWN)) { Log.i("event", "shutdown"); } else if (intent.getAction().equals(Intent.ACTION_REBOOT)) { Log.i("event", "reboot"); } } } Then apply in your activity, shutDownReceiver = new ShutDownReceiver(); filter.addAction(Intent.ACTION_REBOOT); filter.addAction(Intent.ACTION_SHUTDOWN); @Override protected void onPause(...