我现在已经见过几次这个问题,但从未见过 xamarin.forms:
当我尝试在 android 12 上部署时,我得到:
com.interiorcircle.interircircledroid:针对 S+(版本 31 及更高版本)要求在创建 PendingIntent 时指定 FLAG_IMMUTABLE 或 FLAG_MUTABLE 之一。 强烈考虑使用 FLAG_IMMUTABLE,只有在某些功能依赖于 PendingIntent 可变时才使用 FLAG_MUTABLE,例如如果它需要与内联回复或气泡一起使用。
显然,需要设置一个标志,但我不知道在哪里。
有人能帮忙吗?
最佳答案
在我的例子中,以下代码修复了运行时错误:
var pendingIntentFlags = (Build.VERSION.SdkInt >= BuildVersionCodes.S)
? PendingIntentFlags.UpdateCurrent | PendingIntentFlags.Mutable
: PendingIntentFlags.UpdateCurrent;
var pendingActivityIntent = PendingIntent.GetActivity(Application.Context, requestCode, activityIntent, pendingIntentFlags);
var pendingIntent = PendingIntent.GetBroadcast(Application.Context, requestCode, intent, pendingIntentFlags);
关于android - XAMARIN.FORMS 安卓 : FLAG_IMMUTABLE needs to be set when targeting Android S+,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71056022/