Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当崩溃发生在 android 中时,我正在尝试重新启动应用程序Thread.UncaughtExceptionHandler。我可以使用当前活动堆栈作为新进程重新启动应用程序吗?如果是,我该怎么做?
Thread.UncaughtExceptionHandler
一种方法是覆盖 Activity 中的 onPause 方法来终止应用程序。像这样:
public class MyActivity extends Activity { @Override public void onPause() { finish(); }
据我所知,一旦你杀死你的进程,垃圾收集器就会运行,属于你的应用程序的所有消耗内存的对象都将被释放,即所有对象都将具有空值。因此,无法使用先前进程的活动堆栈跟踪启动应用程序。