In monodroid for doing some operations i used Intents. For example in one app for both “Saved Search” and “Search” page I had one activity and when I want to called this activity I used codes like this:
var filename = SearchFileList [args.Position];
Intent intent = new Intent (this, typeof(SearchAroundYouActivity));
intent.PutExtra (AppConstants.SearchAction, AppConstants.SavedSearch);
intent.PutExtra (AppConstants.SearchOption, StorageClass .SearchPath +"/" + filename + "/State.rsf");
intent .PutExtra (AppConstants .SavedSearchName , StorageClass .SearchPath +"/" + filename);
StartActivity (intent);
and then in activity on create on used this code:
action = Intent.GetStringExtra (AppConstants.SearchAction);
if (action == AppConstants.SavedSearch) {
NormalFilter = ((RPLApp)Application).typeOfShow.Content .filter .ToString ();
((RPLApp)Application).typeOfShow.Load (Intent.GetStringExtra (AppConstants.SearchOption));
SaveName = Intent .GetStringExtra (AppConstants .SavedSearchName );
}
By this method I can detect whethere load saved data or run a new search.
The question is this: How can we do some thing like this in monotouch?
Maybe it be possible that we define some static variables in screen class and then check their value for this propose, but whether solutions like this is a recommended, good and the best way to doing this?
On iOS, you should be able to pass these values as you would normally do in C# between 2 classes. Android is a little weird in requiring stuff to be serialized and passed through
Intent.So for example you could do something like this in a click event:
If you want to get even more “cross-platform-y”, you could use a messenger implementation for both platforms. I have one here, and I think MvvmCross is working on one–not sure if it’s in there yet.