-2
私のアプリを終了するホームボタンをクリックしたときにonPause()、 も呼び出したときにロック画面の通知からonCreate )は、最初にアクティビティが破壊されたことはなくても呼び出されます。ユーザはアプリを終了してすべてのアクティビティを破壊するためにバックキーを2回以上押す必要があります。 ユーザーは、アプリを終了するために一度戻るキーを押す必要があります。 これは、ホームボタンを使用してアプリを終了した場合にのみ発生します。 heres a video demo of the bug余分なアクティビティが作成されました/アプリケーションを一時停止するときにonCreate()が呼び出され、ロック画面から再開
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
protected void onResume() {
super.onResume();
Toast.makeText(getApplicationContext(), "onResume", Toast.LENGTH_SHORT).show();
buttonToggleDetect.setBackground(ui.uiToggle(getApplicationContext(), detectEnabled));
// ACTIVITY RECOGNITION BELOW
LocalBroadcastManager.getInstance(this).registerReceiver(mBroadcastReceiver, new IntentFilter(Constants.STRING_ACTION));
// ACTIVITY RECOGNITION ABOVE ^^
mTracker.setScreenName("Image~" + name);
mTracker.send(new HitBuilders.ScreenViewBuilder().build());
}
@Override
protected void onPause() {
Toast.makeText(getApplicationContext(),"onPause",Toast.LENGTH_SHORT).show();
LocalBroadcastManager.getInstance(this).unregisterReceiver(mBroadcastReceiver);
super.onPause();
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onStart() {
super.onStart();
Toast.makeText(getApplicationContext(), "onStart", Toast.LENGTH_SHORT).show();
// ACTIVITY RECOGNITION BELOW
mGoogleApiClient.connect();
// ACTIVITY RECOGNITION ABOVE ^^
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
detectEnabled = preferences.getBoolean("mode", false);
buttonToggleDetect.setBackground(ui.uiToggle(getApplicationContext(), detectEnabled));
}
@Override
public void onStop() {
super.onStop();
Toast.makeText(getApplicationContext(),"onStop",Toast.LENGTH_SHORT).show();
// ACTIVITY RECOGNITION BELOW
if (mGoogleApiClient.isConnected()) {
mGoogleApiClient.disconnect();
}
// ACTIVITY RECOGNITION ABOVE ^^
}
public void onDestroy() {
super.onDestroy();
Toast.makeText(getApplicationContext(),"onDestroy",Toast.LENGTH_SHORT).show();
} //onDestroy End
それを修正する方法を見つけ出す傾けます。 ご協力いただければ幸いです!ありがとう。
コードを投稿してください –
コードに追加してください –