Android - startActivityForResult immediately triggering onActivityResult

前端 未结 13 1176
感情败类
感情败类 2020-11-27 10:54

I am launching activities from the main activity in my app using the call startActivityForResult(intent, ACTIVITY_TYPE), and they are all working but one.

13条回答
  •  暖寄归人
    2020-11-27 11:43

    For ActivityGroup or TabHost and others, maybe the xxxActivity is a subActivity of its parent. Then the startActivityForResult can not work but the parent can get the result.

    1. call getParent().startActivityForResult() from your sub-activity

    2. your parent (the ActivityGroup) will be able to handle the onActivityResult. So I created a subclass of ActivityGroup and handled this onActivityResult.

    3. You can re-route that result back to the sub-activity if you need to. Just get the current activity by getLocalActivityManager().getCurrentActivity() . My sub-activities inherit from a custom activity so I added a handleActivityResult(requestCode, resultCode, data) in that subclass for the ActivityGroup to call.

    example: http://www.cnblogs.com/relinson/archive/2012/03/25/startActivityForResult.html

提交回复
热议问题