美文网首页
android:exported needs to be exp

android:exported needs to be exp

作者: 寻找无名的特质 | 来源:发表于2022-11-15 05:46 被阅读0次

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

相关文章

网友评论

      本文标题:android:exported needs to be exp

      本文链接:https://www.haomeiwen.com/subject/tjlrxdtx.html