Does the system include any intentions during factory reset and system updates?

how to find factory reset is called in android

+5
source share
2 answers

no events to track factory reset

0
source

An old topic, but maybe it will help someone.

The official event does not indicate that Factory Data Reset will be executed. However, for Android <= 22 (Lollipop) there is an unofficial (hidden in the code) translation of the intent android.intent.action.MASTER_CLEAR, which starts when formatting the external storage. If you click Factory Reset for Android settings, then MASTER_CLEAR is washed, as a result you can specify that there will be Factory reset.

Code example:

// Class Member 
private BroadcastReceiver receiver;
.
.
.

// In some method, e.g. onCreate()
IntentFilter filter = new IntentFilter();
filter.addAction("android.intent.action.ACTION_SHUTDOWN");
filter.addAction("android.intent.action.MASTER_CLEAR");

receiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction().equals(
                    Intent.ACTION_SHUTDOWN)) {
                Log.d(TAG, "SHUTDOWN")
            }

            if (intent.getAction().equals("android.intent.action.MASTER_CLEAR")) {
                Log.d(TAG, "FACTORY DATA RESET")
            }
        };

registerReceiver(receiver, filter);

Factory Reset, MASTER_CLEAR, SHUTDOWN. Nexus 5 Androids 4.4.4, 5.0, 6.0, 6.0.1 .

+4

All Articles