Friday, 18 January 2019

Broadcast Receiver for ACTION_USER_PRESENT,ACTION_SCREEN_ON,ACTION_BOOT_COMPLETED

I am creating a class which uses broadcast receiver. I want to receive the broadcast on unlocking of the phone. But there is some issue. Please help me out.

My Manifest.xml is :-

<receiver android:name=".MyReciever">
    <intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.ACTION_USER_PRESENT" />
            <action android:name="android.intent.action.ACTION_BOOT_COMPLETED" />
            <action android:name="android.intent.action.ACTION_SCREEN_ON" />
        </intent-filter>
    </intent-filter>
</receiver>

and my Broadcast reciever class :-

public class MyReiever extends BroadcastReceiver {

   @Override
   public void onReceive(Context context, Intent intent) {
   Log.d("My Reciever","is intent null => " + (intent == null));
   Log.d("My Reciever",intent.getAction()+"");
   }
}

Though other application and services are receiving broadcast for "Screen_on" and "USer_Present" eg. WifiService.



from Broadcast Receiver for ACTION_USER_PRESENT,ACTION_SCREEN_ON,ACTION_BOOT_COMPLETED

No comments:

Post a Comment