In my Xamarin Forms app using MSAL, the UWP project runs and authenticates as expected. However, the Android project "hangs" after the sign-in is partially completed. "Sign In", "Are You Trying " screen, then hangup, …. With the UWP project, "Sign In" and then project continues.
If I created an app with a Blank Template and just a single Main Page, my code works correctly, the user is Authenticated and program completes as expected. However, if I change the program to a Tabbed Template with multiple pages, the program "hangs" during Authentication.
I have added the code to the Android MainActivity.cs file.
I've tried to change the line with the following because this is where I'm stuck.
> global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
App.ParentWindow = this
Here is my MainActivity.cs
> [Activity(Label = "MyEMR", Icon = "@mipmap/icon", Theme = "@STYLE /MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
App.ParentWindow = this;
}
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
{
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(requestCode, resultCode, data);
}
}