android:exported needs to be explicitly specified for element

今天使用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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容