Android 从AlertDialog访问设备主屏幕
我已将AlertDialog添加到服务中 但是,当出现此AlertDialog时,我的主屏幕显示在后台 当我在AlertDialog上按“Ok”时,通知将消失,但我将留在我的应用程序的主屏幕上,而我希望在我的设备的默认主屏幕上,而不是在应用程序上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))
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;
}
有人知道我单击警报对话框上的“确定”按钮后如何显示设备主屏幕而不是应用程序主屏幕吗