![](/img/trans.png)
[英]Android - savedInstanceState can be restored only in onRestoreInstanceState() not in onCreate()
[英]Android onRestoreInstanceState(Bundle savedInstanceState)
在我的應用程序正常操作期間,執行onRestoreInstanceStatance函數並在某些偵聽器中導致空指針異常,而不調用該偵聽器。 我的應用程序包含大量數據,我在onPause中寫入文件並在onResume和onRestoreInstanceStatance中恢復。 如何讓應用程序穩定?
確保在onResume
的末尾分配偵聽器,這將確保在設置初始狀態之前不會觸發偵聽器。 然后在onPause
首先要做的是刪除監聽器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.