显示在Android框架Toast通知框架、通知、Android、Toast

2023-09-04 05:08:08 作者:再相见.

我想通过当密码验证完成后显示在PasswordUnlockScreen.java文件的Toast通知修改的Andr​​oid框架。我已经添加了code以下行verifyPasswordAndUnlock()

  Toast.makeText(getApplicationContext(),验证密码,Toast.LENGTH_LONG).show();
 

不过,我得到的生成错误:

frameworks/base/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java:166:找不到符号符号:方法getApplicationContext() 位置:类com.android.internal.policy.impl.PasswordUnlockScreen Toast.makeText(getApplicationContext(),验证密码,Toast.LENGTH_LONG).show();

我应该为背景,而不是getApplicationContext()?

使用

谢谢!

解决方案

试试这个:

  Toast.makeText(PasswordUnlockScreen.this,验证密码,Toast.LENGTH_LONG).show();
 
Android解码框架

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!

解决方案

Try this one :

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