今天使用Xamarin编写Android应用,遇到如下问题:
android:exported needs to be explicitly specified for element <activity#crc6411a05f7b375e9d5d.OidcCallbackActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for android:exported
when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. PoemApp C:\DDD\PoemGame\PoemApp\PoemApp\obj\Debug\100\AndroidManifest.xml
在系统生成的AndroidManifest.xml中增加android:exported=true可以解决这个问题,但这个文件是系统自动生成的,重新编译后问题又出现了。正确的方法是在代码的标签中声明这个属性:
[Activity(Label = "OidcCallbackActivity",Exported=true)]
[IntentFilter(new[] { Intent.ActionView },
Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
DataScheme = "io.identitymodel.native",
DataHost = "callback")]
public class OidcCallbackActivity : Activity
在Activity中增加Exported=true