简体   繁体   中英

Handle Data Received in onActivityResult with MVP

I have two Activities - Activity A, Activity B. How to retrieve the <Object> data send 'BACK' from from Activity B to Activity A.
I know 'onActivityResult' needs to be overridden in Activity A to get the Model Object data from Activity B.
But using MVP Architecture how can we achieve the same.
Can we handle Model Object related data in onActivityResult method of Activity class in MVP pattern.

It depends on the data that you would like to send from one activity to the other. If you are talking about primitive data you could use the sharedpreferences. Otherwise go with SQLite or internal storage ( https://developer.android.com/guide/topics/data/data-storage.html ). You could also take a look at Parcelable ( https://guides.codepath.com/android/using-parcelable )

Another way would be to use fragments to transition from and to and use the parent activity to store the data. If the screens are very similar from a data perspective I would opt for fragments instead of Activity transition.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM