fm/fmapp2/src/com/caf/fmradio/FMRadioService.java
public void registerScreenOnOffListener() {
        if (mScreenOnOffReceiver == null) {
            mScreenOnOffReceiver = new BroadcastReceiver() {
                @Override
                public void onReceive(Context context, Intent intent) {
                    String action = intent.getAction();
                    if (action.equals(Intent.ACTION_SCREEN_ON)) {
                       Log.d(LOGTAG, "ACTION_SCREEN_ON Intent received");
                       //Screen turned on, set FM module into normal power mode
                       mHandler.post(mScreenOnHandler);
                    }
                    else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
                       Log.d(LOGTAG, "ACTION_SCREEN_OFF Intent received");
                       //Screen turned on, set FM module into low power mode
                       mHandler.post(mScreenOffHandler);
                    }
                }
            };
            IntentFilter iFilter = new IntentFilter();
            iFilter.addAction(Intent.ACTION_SCREEN_ON);
            iFilter.addAction(Intent.ACTION_SCREEN_OFF);
            registerReceiver(mScreenOnOffReceiver, iFilter);
        }
    }
/**
     * Registers an intent to listen for
     * ACTION_SCREEN_ON/ACTION_SCREEN_OFF notifications. This intent
     * is called to know iwhen the screen is turned on/off.
     */
Registers an intent to listen for
ACTION_SCREEN_ON/ACTION_SCREEN_OFF notifications. This intent
is called to know iwhen the screen is turned on/off.
Registers an intent to listen for ACTION_SCREEN_ON / ACTION_SCREEN_OFF notifications . This intent is called to know iwhen the screen is turned on / off .
public void registerScreenOnOffListener() {
        if (mScreenOnOffReceiver == null) {
            mScreenOnOffReceiver = new BroadcastReceiver() {
                @Override
                public void onReceive(Context context, Intent intent) {
                    String action = intent.getAction();
                    if (action.equals(Intent.ACTION_SCREEN_ON)) {
                       Log.d(LOGTAG, "ACTION_SCREEN_ON Intent received");
                       mHandler.post(mScreenOnHandler);
                    }
                    else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
                       Log.d(LOGTAG, "ACTION_SCREEN_OFF Intent received");
                       mHandler.post(mScreenOffHandler);
                    }
                }
            };
            IntentFilter iFilter = new IntentFilter();
            iFilter.addAction(Intent.ACTION_SCREEN_ON);
            iFilter.addAction(Intent.ACTION_SCREEN_OFF);
            registerReceiver(mScreenOnOffReceiver, iFilter);
        }
    }
public void registerScreenOnOffListener ( ) { if ( mScreenOnOffReceiver == null ) { mScreenOnOffReceiver = new BroadcastReceiver ( ) { @ Override public void onReceive ( Context context , Intent intent ) { String action = intent . getAction ( ) ; if ( action . equals ( Intent . ACTION_SCREEN_ON ) ) { Log . d ( LOGTAG , "ACTION_SCREEN_ON Intent received" ) ; mHandler . post ( mScreenOnHandler ) ; } else if ( action . equals ( Intent . ACTION_SCREEN_OFF ) ) { Log . d ( LOGTAG , "ACTION_SCREEN_OFF Intent received" ) ; mHandler . post ( mScreenOffHandler ) ; } } } ; IntentFilter iFilter = new IntentFilter ( ) ; iFilter . addAction ( Intent . ACTION_SCREEN_ON ) ; iFilter . addAction ( Intent . ACTION_SCREEN_OFF ) ; registerReceiver ( mScreenOnOffReceiver , iFilter ) ; } }
Registers an intent to listen for
 ACTION_SCREEN_ON/ACTION_SCREEN_OFF notifications.
Registers an intent to listen for ACTION_SCREEN_ON / ACTION_SCREEN_OFF notifications .
//Screen turned on, set FM module into normal power mode //Screen turned on, set FM module into low power mode