My Xamarin.Forms application uses Azure AD B2C for authentication. Currently, I have to use Android 12 instead of Android 10. According to the documentation, it required a certain change:
Warning: If an activity, service, or broadcast receiver uses intent filters and doesn't have an explicitly-declared value for android:exported, your app can't be installed on a device that runs Android 12 or higher.
(https://developer.android.com/about/versions/12/behavior-changes-12#security)
This is my code from MsalActivity.cs:
namespace UserDetailsClient.Droid
{
[Activity(Exported = false)]
[IntentFilter(new[] { Intent.ActionView },
Categories = new[] { Intent.CategoryBrowsable, Intent.CategoryDefault },
DataHost = "auth",
DataScheme = "msal5c32fe58-4a77-49ea-8b5d-010c4a684e4f")]
public class MsalActivity : BrowserTabActivity
{
}
}
After I added (Exported = false), I was able to deploy and run the app. But now I am not able to log in. The login screen does show up. And the user can enter the credentials, but after submitting, we get stuck on this screen:
Nothing new appears in the output window. How can this be diagnosed and fixed?
No, you need to set the Exported = true. The official document says if the activity has any intent filter, the default value of it is true, so your project in Android 10, it's Exported = true
. When you update to Android 12, you need to set it as true too.
You can check the official document:https://developer.android.com/guide/topics/manifest/activity-element