model view controller - Simple MVC in android; passing object to activities -


i have started working android development , trying grasp relatively simple concept believe. background question first.

i had created java program using mvc design pattern (the view , controller linked though). in project, had created own class model, , in main() function, created single instance of model class, passed on of other classes. allowed every class (and therefore, every view) have same model object, , hence, of updates done model class different controllers.

i wondering how work in android's activities? possible each activity have reference same, single model class object? example, lets have android application has home page stuff on it. on home page, there button lets go "settings" page, starts new activity allows user change settings. able pass model object "settings" activity, have user make whatever changes possible on "settings" activity, update model accordingly, when return home page, model object contains these changes.

is possible? overcomplicating things?

it depends of model structure. if model complicated, make static singleton created application class , obtain reference wherever want.

http://www.devahead.com/blog/2011/06/extending-the-android-application-class-and-dealing-with-singleton/

or can make model parcelable , pass through intent. bit more complicated.

to pass data activity, can use parcelable or serializable in intent extras. modified result, can use startactivityforresult , onactivityresult.

http://shri.blog.kraya.co.uk/2010/04/26/android-parcel-data-to-pass-between-activities-using-parcelable-classes/

how return result (startactivityforresult) tabhost activity?

http://developer.android.com/reference/android/os/parcelable.html

http://developer.android.com/reference/android/content/intent.html


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -