If you are in safe mode, the desktop does not have the application icon you tested or the Xiaomi android 4.1.1 system getLaunchIntentForPackage is empty, you can use setComponent to exit to the login interface
@Override
public void onQuit() {
final CustomAlertDialog.Builder builder = new CustomAlertDialog.Builder (
this);
builder.setMessage(R.string.quit_login_dialog_title);
builder.setPositiveButton(getResources().getString(R.string.ok),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which ) {
if (getApplicationContext() == null) {
return;
}
dialog.dismiss();
final ProgressDialog progressDialog = new ProgressDialog(
ProfileSettingActivity.this);
progressDialog.setMessage(ResourcesManager
.getString(R.string.quit_tip));
progressDialog.setCancelable(false);
UIUtil.showDialogSafe(progressDialog);
AsyncTaskUtils.executeAsyncTask(
new AsyncTask<Void, Void, Boolean>() {
protected Boolean doInBackground(
Void... params) {
UserPrefs.getInstance().setLogin(false);
UserPrefs.getInstance().setAgainSign(
true);
UserPrefs.getInstance().saveToken(null);
return true;
}
@Override
protected void onPostExecute(Boolean result) {
UIUtil.dismissDialogSafe(progressDialog);
MainActivity.resetStartingLoadingPage();
String packAgeName = getPackageName();
final Intent intent = getPackageManager().getLaunchIntentForPackage(packAgeName);
if(intent != null){
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}else{
Intent newIntent = new Intent(Intent.ACTION_MAIN);
newIntent.setComponent(new ComponentName(packAgeName,"com.android.xxx.activity.MainActivity"));
newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(newIntent);
}
finish();
}
}, Priority.HIGH);
}
});
builder.setNegativeButton(getResources().getString(R.string.cancel),
new android.content.DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.build().show();
}
Exit the app
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326816425&siteId=291194637
Recommended
Ranking