How to do we capture quick settings toggle? eg if wifi is switched on or off from quick settings then how will my app get to know about this event?

Created a BroadcastReceiver to capture the WifiManager.WIFI_STATE_CHANGED_ACTION but for some reason the broadcast receiver just doesn't get called on toggling the wifi from quick settings.

Following is the code in

MainActivity.java

IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
registerReceiver(dataWifiReceiver, intentFilter);

BroadcastReceiver

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.i(TAG, "onReceive: inside onReceive method");
        final String action = intent.getAction();
        Log.i(TAG, "onReceive: "+ action);
        if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action)) {
                Log.i(TAG, "onReceive: wifi toggled");
        }
    }

I was hoping BroadcastReceiver to be called and executed but it did not, so wanted to know what is the action for capturing quick settings toggle?

0 Answers