Search code examples
androidmvp

MVP New Activity Initialization


Most MVP Architecture Tutorials online seem to have some clickable view (Button) to process user interaction: view asks the presenter what to do, presenter retrieves some data from the model, presenter then gives it back to the view for it to be shown to the user.

But what about transferring to another Activity? Do we do the processing during onCreate? What about getting the extras on the Intent? - Should it be placed on the Activity?


Solution

  • As of MVP you are processing data in your presenter and pass it back to your view. Where you use this data to display.

    As you have your data in your view it means you already have data(Model) reference in you view(activity) so you can transfer it to another view(activity) with in view.

    As in most of case your one activity reference to only one presenter so ho would you take data from another presenter without having reference of it.

    If you want to start another activity you must have context reference to start. So it should be the best option to start activity and pass those data in extra from activity it self.