Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 从AlertDialog访问设备主屏幕_Android_Android Intent_Android Service_Android Alertdialog - Fatal编程技术网

Android 从AlertDialog访问设备主屏幕

Android 从AlertDialog访问设备主屏幕,android,android-intent,android-service,android-alertdialog,Android,Android Intent,Android Service,Android Alertdialog,我已将AlertDialog添加到服务中 但是,当出现此AlertDialog时,我的主屏幕显示在后台 当我在AlertDialog上按“Ok”时,通知将消失,但我将留在我的应用程序的主屏幕上,而我希望在我的设备的默认主屏幕上,而不是在应用程序上 String appName = (String) packageManager.getApplicationLabel(applicationInfo); if (lockedApps.contains(appName))

我已将AlertDialog添加到服务中

但是,当出现此AlertDialog时,我的主屏幕显示在后台

当我在AlertDialog上按“Ok”时,通知将消失,但我将留在我的应用程序的主屏幕上,而我希望在我的设备的默认主屏幕上,而不是在应用程序上

     String appName = (String) packageManager.getApplicationLabel(applicationInfo);
        if (lockedApps.contains(appName)) {
            showMyDialog();
            Intent dialogIntent = new Intent(this, MyDialog.class);
            dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(dialogIntent);
        }else{
            //Toast.makeText(this, "App in foreground: " + appsInForeground, Toast.LENGTH_LONG).show();
        }
        return Service.START_REDELIVER_INTENT;
    }

 public boolean showMyDialog(){
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_HOME);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
        return true;
    }
有人知道我单击警报对话框上的“确定”按钮后如何显示设备主屏幕而不是应用程序主屏幕吗