在我的启动画面中,我做了它,以便检测是否启用了wifi或3g.如果不是,则会出现一个对话框,提示用户退出并打开其中一个.如果它打开,则代码将继续.我的logcat中一直有一个关于我的活动有一个泄漏窗口的错误.我不知道如何解决这个问题.代码和logcat如下.有任何想法吗?
这是我的代码:
//create alert dialog for wifi and 3g
connectionDialog = new AlertDialog.Builder(SplashMain.this).create();
Log.d(TAG, "dialog created");
connectionDialog.setTitle("Wifi or 3G not detected. Please enable either Wifi or 3G");
connectionDialog.setButton("Exit", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
wifiHandler = new Handler();
setContentView(R.layout.splashscreen); //Make the splash screen load first
Thread splashScreenTimer = new Thread(){ //create a timer for the splash screen
public void run(){ //create a run class
Looper.prepare(); //prepare looper
try{ //methods within the run …Run Code Online (Sandbox Code Playgroud)