Toast message from Broadcast Receiver

后端 未结 3 1843
灰色年华
灰色年华 2021-01-01 14:54

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.

相关标签:
3条回答
  • 2021-01-01 15:06

    Use this

    Toast.makeText(context, "this is not shown",Toast.LENGTH_LONG).show();

    0 讨论(0)
  • 2021-01-01 15:10

    you forgot to call show() on the Toast.. although i would not recommend creating toasts from BroadcastReceivers.. you might consider using Notifications

    0 讨论(0)
  • 2021-01-01 15:14

    Call the show() method for the Toast.

    0 讨论(0)
提交回复
热议问题