Displaying a Toast notification in Android framework

时光总嘲笑我的痴心妄想 提交于 2019-12-02 14:41:10

问题


I'm trying to modify the Android framework by displaying an Toast notification in the PasswordUnlockScreen.java file when a password verification is done. I've added the following line of code in verifyPasswordAndUnlock()

Toast.makeText(getApplicationContext(), "Verifying password", Toast.LENGTH_LONG).show();

However, I get the build error:

frameworks/base/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java:166: cannot find symbol symbol  : method getApplicationContext()
location: class com.android.internal.policy.impl.PasswordUnlockScreen
Toast.makeText(getApplicationContext(), "Verifying password", Toast.LENGTH_LONG).show();

What should I use as the context instead of getApplicationContext()?

Thanks!


回答1:


Try this one :

Toast.makeText(PasswordUnlockScreen.this, "Verifying password", Toast.LENGTH_LONG).show();


来源:https://stackoverflow.com/questions/11304267/displaying-a-toast-notification-in-android-framework

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!