Why the toast message is not displayed in the Android 4.1 operating system containing a mobile

I can not see the toasts in the Android 4.1 mobile phone. Until yesterday, I was able to see a toast message. From today, only I do not see the message. Please help me.

Toast.makeText(getApplicationContext(), "hi", Toast.LENGTH_SHORT).show(); 

I tried not only a toast message, but also a toast message. But still not working.

Custom Toast:

 LayoutInflater inflater=getLayoutInflater(); View layout = inflater.inflate(R.layout.toast_layout,(ViewGroup) findViewById(R.id.toast_layout_root)); TextView text = (TextView) layout.findViewById(R.id.text); text.setText("Please fill Name"); Toast toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.setView(layout); toast.show(); 
+8
android toast android-4.2-jelly-bean
source share
5 answers

Change this and check again.

 if(first_name.length() == 0) { Toast.makeText(NameOfYourActivity.this, "Please fill Name", Toast.LENGTH_SHORT).show(); Utilities.writeIntoLog("Please fill Name"); } 
+8
source share

Toast did not show up with me in Android 4.1, because Show Notifications was disabled in the settings of my application. I just went to Settings-> Application Management → [My Application] and switched to showing notifications and toasts.

+48
source share

just post the google code link here.

Since Jelly Bean, users can turn off notifications for this application through the "Application Details" settings.

A very bad and undesirable side effect is that when notifs are disabled, Toast messages are also disabled, even when the user launches the application!

You encourage the use of Toast in your design recommendations, but who wants to use it if users have the option to remove them, especially if this message is an important feedback to display to the user ...

At least I understand that Toasts can be disabled when the application is in the background, but not if this is the main action.

+7
source share

Toast works great in all versions of Android. There may be several problems in your code, for example

  • Your context is not wrong
  • You are trying to display a toast in a background thread instead of a workflow.

Edit In your regular toast, do not set the parent in your bloat layout, for example, use as shown below.

 View layout = inflater.inflate(R.layout.toast_layout,null); 
+2
source share

I had the same problem. When I called the code in the user interface thread, the problem was solved for me

 public void showToastMessage(final String msg) { runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(BaseActivity.this, msg, Toast.LENGTH_LONG).show(); } }); } 
0
source share

All Articles