My code list as follow:
public class MainActivity extends Activity{
private String TAG = "MainActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d(TAG, "onCreate");
}
@Override
public void onBackPressed() {
Log.d(TAG, "onBackPressed");
moveTaskToBack(true);
}
@Override
protected void onStart() {
Log.d(TAG, "onStart");
super.onStart();
}
@Override
protected void onResume() {
Log.d(TAG, "onResume");
super.onResume();
}
@Override
protected void onPause() {
Log.d(TAG, "onPause");
super.onPause();
}
@Override
protected void onStop() {
Log.d(TAG, "onStop");
super.onStop();
}
@Override
protected void onDestroy() {
Log.d(TAG, "onDestroy");
super.onDestroy();
}
}
My test result is:
11-29 15:20:09.850 4626 4626 D MainActivity: onCreate
11-29 15:20:09.851 4626 4626 D MainActivity: onStart
11-29 15:20:09.852 4626 4626 D MainActivity: onResume
11-29 15:20:18.887 4626 4626 D MainActivity: onBackPressed
11-29 15:20:18.909 4626 4626 D MainActivity: onPause
11-29 15:20:19.718 4626 4626 D MainActivity: onStop
11-29 15:20:29.471 4626 4626 D MainActivity: onStart
11-29 15:20:29.471 4626 4626 D MainActivity: onResume
11-29 15:20:32.030 4626 4626 D MainActivity: onBackPressed
11-29 15:20:32.050 4626 4626 D MainActivity: onPause
My Test Step:
Enter any 3rd App's Ui;
Use eclipse to run or debug my app, then my app will cover the 3rd app and be shown on the top;
Then press back-key many times as quickly as I can and go to desktop (home launcher).
If the result has onStop, maybe your press not so quick and then try.
Now I want to know whether the activity is visuable, but sometimes the onStop can't be called, please help me. thank you!