Skip to content

Commit

Permalink
support exit for ActivityManager
Browse files Browse the repository at this point in the history
  • Loading branch information
yjfnypeu committed Nov 6, 2018
1 parent c5e84c7 commit 36c6fc9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Process;

import org.lzh.framework.updatepluginlib.base.DownloadCallback;
import org.lzh.framework.updatepluginlib.base.DownloadNotifier;
Expand Down Expand Up @@ -77,8 +75,7 @@ private void createRestartDialog() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (update.isForced()) {
System.exit(0);
Process.killProcess(Process.myPid());
ActivityManager.get().exit();
} else {
dialog.dismiss();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.os.Process;

import java.util.LinkedList;

Expand Down Expand Up @@ -92,4 +93,14 @@ void registerSelf(Context context) {
this.applicationContext = context.getApplicationContext();
}

public void exit() {
Activity activity;
while ((activity = stack.pop()) != null) {
if (!activity.isFinishing()) {
activity.finish();
}
}
System.exit(0);
Process.killProcess(Process.myPid());
}
}

0 comments on commit 36c6fc9

Please sign in to comment.