Why toast message are not show in android 4.1 operating system containing mobile

前端 未结 5 1492
[愿得一人]
[愿得一人] 2021-01-12 03:38

I cant see the toast message in android 4.1 mobile. Upto yesterday I was able to see the toast message. From today only I can not see the message. Please help me.

         


        
相关标签:
5条回答
  • 2021-01-12 03:54

    I had the same problem. When I invoked the code on UI thread the issue resolved 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 讨论(0)
  • 2021-01-12 03:56

    Toast was not showing with me in Android 4.1 because Show Notifications was checked off in my app's settings. I just went to Settings->Manage Applications->[My App] and toggled on Show Notifications and Toasts started to appear.

    0 讨论(0)
  • 2021-01-12 04:00

    just post the google code link here.

    Since Jelly Bean, users can disable notifications for a given app via "app details" settings.

    A very bad and unwanted side effect is that once notifs are disabled, Toast messages are also disabled, even when the user is running the app!

    You encourage to use Toast in your design guidelines, but who will want to use it if the users have the possibility to remove them, especially if the toasted message is an important feedback to display to the user...

    I understand at least that Toasts could be disabled when the app is in background, but not if it is the foreground Activity.

    0 讨论(0)
  • 2021-01-12 04:06

    Change to 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"); 
    }
    
    0 讨论(0)
  • 2021-01-12 04:08

    Toast is working fine in all the version of Android. There can be couple of issues in your code like

    1. Your context is not wrong
    2. You are trying to display toast in the background thread instead of worker thread.

    Edit In your custom toast don't set the parent in your layout inflater for example use like below

    View layout = inflater.inflate(R.layout.toast_layout,null);
    
    0 讨论(0)
提交回复
热议问题