从广播接收机吐司消息吐司、接收机、消息

2023-09-06 02:06:36 作者:傲气

我有一个广播接收器,我试图从它显示敬酒消息,这可能吗? 这code不显示敬酒,但它在打印的logcat日志消息。有一些愚蠢的事情我做或什么是我的问题?

  @覆盖
公共无效的onReceive(上下文的背景下,意图意图){
    Log.v(日志,这显示);
    Toast.makeText(背景下,这是不是显示,Toast.LENGTH_LONG);
}
 

解决方案

致电显示()方法为吐司

I have a broadcast receiver and I am trying to show a toast message from it, is this possible ? This code doesn't show the toast but it print the log message in the logcat. Is there some idiotic thing I am doing or what is my problem ?

@Override
public void onReceive(Context context, Intent intent) {
    Log.v("log", "this is shown");
    Toast.makeText(context, "this is not shown"     , Toast.LENGTH_LONG);
}
东升黑白电视广播接收机

解决方案

Call the show() method for the Toast.