警告对话框中的非活性类 [英] Alert Dialog in non activity class

查看:140
本文介绍了警告对话框中的非活性类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个code的检查一些数据并显示在非活性类警报。但运行时应用程序崩溃,并且不显示警告对话框。我用低于code ...

I have a code which checks some data and shows an alert in a non activity class. But while running application program crashed and does not showing alert dialog. I used below code...

if( str.isEmpty() || strPort.isEmpty()){
        new AlertDialog.Builder(Mtx.getContext())
                    .setMessage("Please provide a valid String")
        .setTitle("HAT Alert !!!")
        .setCancelable(true)
        .setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton){
                return;
            }
        }).show();

$ C $下Mtx.getContent()方法

code for Mtx.getContent() method

public class Mtx extends Application {
public static Context context;

@Override
public void onCreate(){
   super.onCreate();
   Mtx.context = getApplicationContext();
}

public static Context getContext(){
       return Mtx.context;
}
}

显示日志猫错误信息

error message showing in log cat

10-15 12:50:33.708: E/global(329): Deprecated Thread methods are not supported.
10-15 12:50:33.708: E/global(329): java.lang.UnsupportedOperationException
10-15 12:50:33.708: E/global(329):  at java.lang.VMThread.stop(VMThread.java:85)
10-15 12:50:33.708: E/global(329):  at java.lang.Thread.stop(Thread.java:1280)
10-15 12:50:33.708: E/global(329):  at java.lang.Thread.stop(Thread.java:1247)
10-15 12:50:33.708: E/global(329):  at mediatronix.HAT.Splash$1.run(Splash.java:36)

请指正

感谢

推荐答案

你确定,该对话框是什么问题?是什么在你的 Splash.java行36 文件?因为根据堆栈跟踪,有问题。

Are you sure, the dialog is the problem? What is at line 36 of your Splash.java file? Because according to the stacktrace, there's the problem.

这篇关于警告对话框中的非活性类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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