0
我有下一個要求:如果設備在計算過程中重新啓動,那麼應用程序應該繼續從設備關機點的同一點開始完成啓動計算。所以我想在關閉手機之前保存我的數據。我正在使用廣播接收器。我的broadcastReceiver應該在用戶關機時觸發。爲此我使用關機前如何保存數據?
IntentFilter filter = new IntentFilter(Intent.ACTION_SHUTDOWN);
BroadcastReceiver receiver = new ShutdownReceiver();
registerReceiver(receiver,filter);
但我不知道如何通過這個過濾器把額外的數據。所以我認爲這將是很好的使用這樣的smt:
shutdownIntent = new Intent(this,ShutdownReceiver.class);
shutdownIntent.setAction(intent.ACTION_SHUTDOWN);
shutdownIntent.putExtra(getResources().getString(R.string.progresStatus), value[0]);
但如何把這個意圖到接收器?非常感謝
[Android在內部/外部存儲中保存應用程序設置/數據]的可能重複(http://stackoverflow.com/questions/8119122/android-save-app-settings-data-in-internal-external-storage) – 323go
我忘了說我正在使用服務,這是一個長時間的計算。所以如果用戶關掉手機,我需要在手機開機後立即開始計算 –