Take the 2-minute tour ×

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 ?

public void onReceive(Context context, Intent intent) {
    Log.v("log", "this is shown");
    Toast.makeText(context, "this is not shown"     , Toast.LENGTH_LONG);
share|improve this question
As lukuluku suggests, creating a Toast from a BroadcastReceiver isn't necessarily a good thing to do. It's possible your BroadcastReceiver may be 'alive' when some other Activity is in use. In this case, the Toast will make no sense to the user of the device. –  Squonk Oct 26 '11 at 10:22
add comment

3 Answers

up vote 13 down vote accepted

Call the show() method for the Toast.

share|improve this answer
tnx, I am complete idiot –  Lukap Oct 26 '11 at 9:43
add comment

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

share|improve this answer
add comment

If I remember android correctly, this: Toast.makeText(context, "this is not shown" , Toast.LENGTH_LONG).show();

share|improve this answer
add comment

Your Answer


