I have defined a BroadCastReceiver in AndroidManifest.xml as below
<receiver
android:name="com.example.hello.ScreenUnlockReceiver"
android:enabled="true"
android:singleUser="true">
<intent-filter>
<action android:name="android.content.Intent.ACTION_USER_PRESENT" />
</intent-filter>
</receiver>
and defined the Receiver as below :
public class ScreenUnlockReceiver
extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
//start activity
Intent i = new Intent();
i.setClassName("com.example.hello", "LoginActivity");
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
But the broadcastreceiver is not triggered when I unlock the screen and the LoginActivity is not being shown. LoginActivity is the default loginactivity which comes with android sdk.
Am I missing something in uses-permission or something else, please let me know. Thanks
Santhosh
The action you have to intercept is:
<intent-filter>
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
Developer Android ACTION_USER_PRESENT
your should fix the problom like thisi.setClassName("com.example.hello", "com.example.hello.LoginActivity")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With