Navigating from Activity A->B->C - How to pass data from C to A in onBackPressed()?

前端 未结 3 1312
春和景丽
春和景丽 2021-01-15 18:37
  1. From Activity A call Activity B
  2. from B to C and while calling Activity C
  3. I call finish for Activity B
3条回答
  •  一整个雨季
    2021-01-15 19:05

    Where're multiple ways of doing this:

    • Store the data from Activity C to Application's object and just read it in Activity A:

         ((MySuperApplication) getApplication()).setMyData(..);
      
    • Pass it as Activity Result

    • Store data to SharedPreference in Activity C and read it in Activity A. If it's a complex data structure - I'd suggest to use gsonto serialize object and store it as a string and then deserialize it in Activity A

    Choose the one you like the most.

提交回复
热议问题