Get back to a fragment from an Activity

前端 未结 10 1966
野趣味
野趣味 2020-12-09 05:10

I have three fragment in an Activity C. they are behaving as tabs. I have to go from a fragment to a new Activity X. Now i want to come back to fragment from Activity X.

10条回答
  •  清歌不尽
    2020-12-09 05:57

    You can start the activity that you are navigating to using startActivityForResult() and then while coming back to the previous activity you set the result.In the activity that you are coming back to,show the fragment depending on the resultcode. You can accomplish this task by hiding all the fragments that you dont want to show. This can work even if you are going to another activity from another fragment.

提交回复
热议问题