Xamarin AndroidRuntimeException “Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag”
In my Android application I’m using the Azure Mobile Services component to connect to Windows Azure.
I want to use the authentication component and let the users login by using their Microsoft account. Here is the code I used:
However when I try to run this code, it fails the moment the LoginAsync method is called. This is the exception I get:
AndroidRuntimeException “Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag”
I found out that I made a stupid mistake. I was passing the BaseContext instead of the Activity itself. When I updated the code to the following it worked as expected: