I want to make an application that would display a message when a user unlocks his/her Android phone. I do not know if this is possible or not.
If anyone has a way to do this, could you please point me in the right direction.
I want to make an application that would display a message when a user unlocks his/her Android phone. I do not know if this is possible or not.
If anyone has a way to do this, could you please point me in the right direction.
Only android.intent.action.USER_PRESENT
action BroadcastReceiver
is enough to do what you need
Yes you can do it by registering android.intent.action.USER_PRESENT
in manifast as:
<receiver android:name=".unlockReceiver">
<intent-filter android:enabled="true" android:priority="90000" android:exported="false">
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
and in unlockReceiver show message as:
public class unlockReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction() != null) {
if( intent.getAction().equals(Intent.ACTION_USER_PRESENT)) {
Toast msg = Toast.makeText(context,"hello User !!! :)", Toast.LENGTH_LONG);
msg.show();
}
}
}
Yes you can do this
In your manifest file write this,
receiver android:name=".MyBroadCastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
<action android:name="android.intent.action.SCREEN_ON" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
and MyBroadCastReceiver implementation is like this
public class MyBroadCastReceiver extends BroadcastReceiver {
Context mContext;
@Override
public void onReceive(Context context, Intent intent) {
mContext = context;
Toast.makeText(mContext, "Phone UNLOCKED", Toast.LENGTH_LONG)
.show();
}
}