-1

Hello guys i want to how to show a toast if the user enters wrong password on lock screen (when keyguard is active) .I googled it 100 of times , but i didnt find answer for it .

@Override
public void onPasswordFailed(Context context, Intent intent) {
    super.onPasswordFailed(context, intent);
    Toast.makeText(context, R.string.wrong_password,
            Toast.LENGTH_LONG).show();
    Log.d(TAG, "onPasswordFailed");

}

@Override
public void onPasswordSucceeded(Context context, Intent intent) {
    super.onPasswordSucceeded(context, intent);
    Log.d(TAG, "onPasswordSucceeded");
    Toast.makeText(context, R.string.success,
            Toast.LENGTH_LONG).show();

added those lines in my DeviceadminReceiver ! It shows a toast after the device is unlocked ! Any help would be really appreciated . Thanks in advance :)

Adam
  • 1
  • 1

1 Answers1

0

You may use the SYSTEM_ALERT_WINDOW to overlay or show a Toast in lock screen. Since its a system level alert so it'll work no matter when or where you want to show the message.

A demo sample could be found here,

Creating a system overlay window (always on top)

For this you'll be needed the following permisson,

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
Community
  • 1
  • 1
Prokash Sarkar
  • 11,723
  • 1
  • 37
  • 50