Xamarin.forms mixes ContentPage and Android content

How can I combine both pages together

I want to do something specific on the (Android) OnActivityResult , but I use ContentPage in Xamarin.Forms

as I know in my .Droid project which activity is this?

Let's say I have a page called CalendarPage : ContentPage where I register it in my droid project, so I can catch an ActivityResult in this Activity (ContentPage).

I have no clue since im new for Xamarin.Forms and learning it

+5
source share
1 answer

Xamarin forms run on one activity, which is most similar to your main activity.

There are two sample projects that show you how to communicate between native and parts of the code form, which can be found here.

However, to answer your question, you would do something like the following

  private const int MyRequestCode = 101; //Start activity for result var contactPickerIntent = new Intent(Intent.ActionPick, Android.Provider.ContactsContract.Contacts.ContentUri); context.StartActivityForResult(contactPickerIntent, MyRequestCode); 

and then in your main action (activity that initializes the application of the xamarin form (using global::Xamarin.Forms.Forms.Init(this, bundle); )

 protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { if (requestCode == MyRequestCode && resultCode == Result.Ok) { } } 
+3
source

Source: https://habr.com/ru/post/1234358/


All Articles