Displaying a Toast notification in Password Unlock Screen

303 views
Skip to first unread message

galapogos

unread,
Sep 18, 2012, 4:14:15 AM9/18/12
to android-...@googlegroups.com

I'm trying to display a Toast notification in verifyPasswordAndUnlock() in PasswordUnlockScreen.java whenever a user enters the wrong password. I wrote the following code, and built successfully.

Toast.makeText(getContext(), "Invalid password", Toast.LENGTH_LONG).show();


However, the Toast doesn't appear, because it actually appears in the home screen, which is invisible when the lock screen is on top. I verified this by having another Toast appear when the user successfully logs in, and that Toast only appears in the home screen after the Lock screen disappears

I suspect this is because getContext() returns the home screen's context. How do I get the Lockscreen's context? PasswordUnlockScreen.this doesn't even compile, and mContext and context both have the same problem as getContext()

M Miles

unread,
Sep 7, 2016, 6:54:18 PM9/7/16
to android-platform
Have you found any solutions to this? Facing the same issue now on my nexus 5x, however on galaxy note 2 the toast displays correctly with the same code

Sihan Goi

unread,
Sep 8, 2016, 3:16:05 AM9/8/16
to android-...@googlegroups.com
Hi,

Sorry, it's been 4 years since I asked that question, so I really don't remember what I did, nor do I have access to the source anymore.

--
You received this message because you are subscribed to a topic in the Google Groups "android-platform" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/android-platform/GWKoP56CM6c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to android-platform+unsubscribe@googlegroups.com.
To post to this group, send email to android-platform@googlegroups.com.
Visit this group at https://groups.google.com/group/android-platform.
For more options, visit https://groups.google.com/d/optout.



--
- Goi Sihan
goi...@gmail.com

liuyafei

unread,
Sep 8, 2016, 10:41:22 AM9/8/16
to android-...@googlegroups.com

The unlock screen aka keyguard in Android is a special window. The toast is a special window, too. You can find that keyguard belongs to systemui, which has the higher privilege/layer than toast (check out this in WindowManager.java), and there are some codes in WindowManagerService to make sure systemui shows on the top.


My solution is to give up toast and use a view instead.

--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-platfo...@googlegroups.com.
To post to this group, send email to android-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages