问题描述:

I'm having an activity A which starts another activity B, I use the startActivityForResult method.

My plan is:

When I press Home button in activity B, I want Activity A to be killed as well.

In the onStop() of activity B, I tried setResult(1,mIntent) and in activity A, when request code ==1, I finish A.

However, when I press home button in B, the setResult method didn't get called.

I'm just wondering anybody knows why is that or is there another way to kill parent activity in child activity when home button pressed?

网友答案:

Try the onUserLeaveHint method:

http://developer.android.com/reference/android/app/Activity.html#onUserLeaveHint%28%29

It executes when the user forces an activity to stop by, for example, clicking the home button

相关阅读:
Top