赞
踩
《第一行代码 Android》第三版
Android Studio Jellyfish | 2023.3.1
A launchable activity must be exported as of Android 12, which also makes it available to other apps
新建的activity中的android:exported="false",如下图所示:
- <activity
- android:name=".FirstActivity"
- android:exported="false"
- </activity>
为程序配置主Activity,代码如下所示:
- <activity
- android:name=".FirstActivity"
- android:exported="false"
- android:label="This is FirstActivity" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
-
- </activity>
此时会出现一个问题:A launchable activity must be exported as of Android 12, which also makes it available to other apps.
将android:exported="false"设置为android:exported="true"。
(原文链接:Android:exported 属性知识-CSDN博客)
1、android:exported 是 Android中的四大组件 Activity,Service,Provider,Receiver 四大组件中都会有的一个属性。
2、android:exported 代表是否能被其他应用隐式调用。
3、true允许被启动,false不允许被启动。
4、android:exported 默认值是由有无intent-filter决定的,如果有intent-filter,默认值为true,否则为false。
5、android:exported = false的情况下,这个Activity将只会被当前Application或者拥有同样user ID的Application的组件调用,对于其他应用,即使有intent-filter匹配,也无法打开,即无法被其他应用隐式调用。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。