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); }
Broadcast in android is the system-wide events that can occur when the device starts, when a message is received on the device or when incoming calls are received, or when a device goes to airplane mode, etc. Broadcast Receivers are used to respond to these system-wide events.
Call the show()
method for the Toast
.
you forgot to call show()
on the Toast
.. although i would not recommend creating toasts from BroadcastReceivers.. you might consider using Notifications
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With