私が構築しているアプリケーションでは、OS がメモリを再利用しているため、バックグラウンドでアプリケーションが終了した場合にのみ、アプリケーションの終了を検出する必要があります。
私自身の実験から、 onDestroy はすべてのインスタンスで呼び出されます。私は isFinishing をチェックしようとしましたが、これがどのような状況にそれを分離するかは 100% わかりません。
@Override
public void onDestroy()
{
super.onDestroy();
Log.i("V LIFECYCLE", "onDestroy");
if (!isFinishing())
{
// are we here because the OS shut it down because of low memory?
ApplicationPreferences pref = new ApplicationPreferences(this);
// set persistant flag so we know next time that the user
// initiated the kill either by a direct kill or device restart.
pref.setThePersistantFlag(true);
Log.i("DEBUG", "onDestroy - ensuring that the next launch will result in a log out..");
}
}
ここで私の問題を明らかにできる人はいますか? ありがとうございました。