diff --git a/updatepluginlib/src/main/java/org/lzh/framework/updatepluginlib/impl/DefaultDownloadNotifier.java b/updatepluginlib/src/main/java/org/lzh/framework/updatepluginlib/impl/DefaultDownloadNotifier.java index d83f0e4..5ae4901 100644 --- a/updatepluginlib/src/main/java/org/lzh/framework/updatepluginlib/impl/DefaultDownloadNotifier.java +++ b/updatepluginlib/src/main/java/org/lzh/framework/updatepluginlib/impl/DefaultDownloadNotifier.java @@ -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; @@ -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(); } diff --git a/updatepluginlib/src/main/java/org/lzh/framework/updatepluginlib/util/ActivityManager.java b/updatepluginlib/src/main/java/org/lzh/framework/updatepluginlib/util/ActivityManager.java index f167227..c54257a 100644 --- a/updatepluginlib/src/main/java/org/lzh/framework/updatepluginlib/util/ActivityManager.java +++ b/updatepluginlib/src/main/java/org/lzh/framework/updatepluginlib/util/ActivityManager.java @@ -19,6 +19,7 @@ import android.app.Application; import android.content.Context; import android.os.Bundle; +import android.os.Process; import java.util.LinkedList; @@ -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()); + } }