吐司消息未显示 [英] Toast message not shown

查看:90
本文介绍了吐司消息未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码在我的应用程序中显示吐司消息.

I am trying to show a toast message in my application using the following code.

AlertDialog.Builder alert = new AlertDialog.Builder(this);
            alert.setTitle("Do you want to continue?");
            alert.setPositiveButton("Continue", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {

                    try{
                        //This code generates an Activity Not Found exception   
                        }
                        catch(ActivityNotFoundException e) {
                            System.out.println("Activity Not Found Exception Raised");
                            Toast.makeText(getBaseContext(), "Activity Not Found", Toast.LENGTH_LONG).show(); // For the context I tried using getBaseContext, ActivityName.this also
                        }
                    }

            });

            alert.setNegativeButton("Cancel",
                    new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                }
            });
            alert.show();

但是此消息仅在少数设备上显示.我已经在运行Android 4.2.2的HTC One X上测试了此代码.

But this message is being shown only on few devices. I've tested this code on HTC One X having Android version 4.2.2 which is working.

如果我在同样具有Android 4.2.2的Micromax A63上进行测试,则使用相同的代码,但是在它上面却无法使用.

The same code if I test on Micromax A63 which is also having Android 4.2.2, but it doesn't work on it.

我已经在Internet上搜索了此类错误,它们主要是在设置菜单中告知应用程序通知禁用选项.但是我的应用程序通知未禁用.

I've searched over Internet for this kind of errors and they are mostly telling about the app notification disabling option in the settings menu. But my application notification are not disabled.

编辑

我正在 AlertDialog

有人可以帮我解决这个问题.

Can someone help me solve this issue.

推荐答案

如果您还没有弄清楚,请确保您尚未禁用有关应用程序的通知;这也会禁用烤面包.

In case you haven't figured this out yet, make sure you haven't disabled notifications for the application in question; this also disables toasts.

https://code.google.com/p/android/issues/detail?id = 35013

这篇关于吐司消息未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆