xamarin - Android Activity LaunchMode SingleTask doesn't trigger MvvmCross ViewModel constructor or Init method -
in order provide correct button behaviour of android app uses mvvmcross, i've had amend launchmode
of particular views singletask
. whilst works fine, when 1 of these views used second time onwards, viewmodel constructor , init methods (used in conjuction nav
class pass parameters 1 view another) no longer fired. presume behaviour "by design" or "enforced android os" need aware of when placing code in constructors/init methods may need called every time view displayed (e.g. refreshjoblist). fix incidentally, place call required method in onresume
method of activity, e.g.:
((jobdetailviewmodel)this.viewmodel).refreshjobphotos();
is there "better way"?
i presume behaviour "by design" or "enforced android os"
if forcing activity singletask
created once viewmodel once.
there onnewintent method override , use work out when happens - mvvmcross has tried use in past - it's use has confused developers - mvx keeps out of way in specialised platform-specific area.
when using singletask
, please aware of android's own warning:
the other modes — singletask , singleinstance — not appropriate applications, since result in interaction model unfamiliar users , different other applications.
from: http://developer.android.com/guide/topics/manifest/activity-element.html#lmode
Comments
Post a Comment