Authenticating the user (using azure authentication provider) works fine. However, when the app is terminated and then launched, we are authenticating the user again and then we get the error
Java.Lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
When trying to authenticate again right after, it crashes with the error message
System.InvalidOperationException: Authentication is already in progress.
Example code:
ProviderHelper provider = ProviderHelper.Google;
var user = await AllInclusive.App.Client.LoginAsync(this, (MobileServiceAuthenticationProvider)provider, "myAppName");//crashes here
}catch(Exception e)
//first login when the app is launched after it has been terminated, we get the Java.Lang.NullPointerException error.
//when trying to login again, it crashes again with the error message "System.InvalidOperationException: Authentication is already in progress."
var messahe = e.Message;
What is the cause of the
Java.Lang.NullPointerException
error, do I need to create a new context for android when authenticating again? Any solutions for that error?
When replacing
this
with
Android.App.Application.Context
I get a (pretty clever) error:
"Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?"
Maybe it's due to
LoginAsync()
that starts a new azure authentication window so somehow we pass a wrong context to another activity?