Prevent Activity Stack from being Restored?

后端 未结 5 546
有刺的猬
有刺的猬 2020-12-02 20:48

When an application\'s process is killed, its activity stack is saved. Then when the application is restarted, all my activities resume and run into null pointers. Rather th

5条回答
  •  伪装坚强ぢ
    2020-12-02 21:14

    The only solution I was able to find was to check a global static variable in every instance of onCreate() and finish if that variable had been reset to null, indicating the task had been restarted. I close all activities down to my root activity and start over.

    Soon I hope to have my app at a point where it can save needed values in onPause(), but 'til then this is the only reliable way I know to work with lost initialization...

提交回复
热议问题