AndroidManifest 中android:exported

本文探讨了Android中Service的跨进程调用问题。详细解释了如何通过修改Service的android:exported属性来实现跨进程间的交互,并讨论了默认值设定的逻辑以及如何使用权限进一步限制交互。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

        如果Service等的AndroidManifest中声明为android:exported="false"
则该服务不能够跨进程使用。
        Permission Denied!

  需要改为:android:exported="true"

android:exported
       这个属性用于指示该服务是否能够被其他应用程序组件调用或跟它交互。如果设置为true,则能够被调用或交互,否则不能。设置为false时,只有同一个应用程序的组件或带有相同用户ID的应用程序才能启动或绑定该服务。
它的默认值依赖与该服务所包含的过滤器。没有过滤器则意味着该服务只能通过指定明确的类名来调用,这样就是说该服务只能在应用程序的内部使用(因为其他外部使用者不会知道该服务的类名),因此这种情况下,这个属性的默认值是false。另一方面,如果至少包含了一个过滤器,则意味着该服务可以给外部的其他应用提供服务,因此默认值是true。
这个属性不是限制把服务暴露给其他应用程序的唯一方法。还可以使用权限来限制能够跟该服务交互的外部实体。

> Task :app:processDebugMainManifest FAILED [com.android.support:animated-vector-drawable:28.0.0] C:\Users\Administrator\.gradle\caches\transforms-3\3648fb114e268826532fb9efd04f940b\transformed\animated-vector-drawable-28.0.0\AndroidManifest.xml Warning: Namespace 'android.support.graphics.drawable' used in: com.android.support:animated-vector-drawable:28.0.0, com.android.support:support-vector-drawable:28.0.0. F:\git13\WatchTest1\app\src\main\AndroidManifest.xml:41:5-75 Warning: Element uses-permission#android.permission.INSTALL_PACKAGES at AndroidManifest.xml:41:5-75 duplicated with element declared at AndroidManifest.xml:10:5-74 F:\git13\WatchTest1\app\src\main\AndroidManifest.xml:47:5-76 Warning: Element uses-permission#android.permission.CHANGE_WIFI_STATE at AndroidManifest.xml:47:5-76 duplicated with element declared at AndroidManifest.xml:35:5-76 F:\git13\WatchTest1\app\src\main\AndroidManifest.xml:61:5-67 Warning: Element uses-permission#android.permission.INTERNET at AndroidManifest.xml:61:5-67 duplicated with element declared at AndroidManifest.xml:31:5-67 F:\git13\WatchTest1\app\src\main\AndroidManifest.xml:64:5-75 Warning: Element uses-permission#android.permission.READ_PHONE_STATE at AndroidManifest.xml:64:5-75 duplicated with element declared at AndroidManifest.xml:19:5-75 F:\git13\WatchTest1\app\src\main\AndroidManifest.xml:65:5-69 Warning: Element uses-permission#android.permission.CALL_PHONE at AndroidManifest.xml:65:5-69 duplicated with element declared at AndroidManifest.xml:22:5-69 F:\git13\WatchTest1\app\src\main\AndroidManifest.xml:91:9-105:20 Error: android:exported needs to be explicitly specified for element <activity#com.dosen.watchtest.MainActivity>. 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. F:\git13\WatchTest1\app\src\main\AndroidManifest.xml:307:9-320:20 Error: android:exported needs to be explicitly specified for element <activity#com.dosen.watchtest.activity.PhotoActivity>. 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. F:\git13\WatchTest1\app\src\main\AndroidManifest.xml:119:9-123:19 Error: android:exported needs to be explicitly specified for element <service#com.dosen.watchtest.alarm.AlarmKlaxon>. 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. F:\git13\WatchTest1\app\src\main\AndroidManifest.xml:111:9-117:20 Error: android:exported needs to be explicitly specified for element <receiver#com.dosen.watchtest.alarm.AlarmReceiver>. 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. F:\git13\WatchTest1\app\src\main\AndroidManifest.xml:125:9-133:20 Error: android:exported needs to be explicitly specified for element <receiver#com.dosen.watchtest.alarm.AlarmInitReceiver>. 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. F:\git13\WatchTest1\app\src\main\AndroidManifest.xml:148:9-152:20 Error: android:exported needs to be explicitly specified for element <receiver#com.dosen.watchtest.receiver.WakeLockBroadCast>. 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. F:\git13\WatchTest1\app\src\main\AndroidManifest.xml:154:9-158:20 Error: android:exported needs to be explicitly specified for element <receiver#com.dosen.watchtest.receiver.CloudOpenReceiver>. 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. F:\git13\WatchTest1\app\src\main\AndroidManifest.xml:160:9-164:20 Error: android:exported needs to be explicitly specified for element <receiver#com.dosen.watchtest.receiver.SmsReceiver>. 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. F:\git13\WatchTest1\app\src\main\AndroidManifest.xml:71:9-76:20 Error: android:exported needs to be explicitly specified for element <receiver#io.rong.callkit.VoIPBroadcastReceiver>. 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. F:\git13\WatchTest1\app\src\main\AndroidManifest.xml:80:9-84:20 Error: android:exported needs to be explicitly specified for element <receiver#io.rong.callkit.util.RTCPhoneStateReceiver>. 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. F:\git13\WatchTest1\app\src\main\AndroidManifest.xml:46:9-61:20 Error: android:exported needs to be explicitly specified for element <receiver#io.rong.push.rongpush.PushReceiver>. 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. 是什么问题
06-12
Androidstudio查看这段在AndroidManifest.xml中的代码是否需要修改或者优化<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"> <uses-permission android:name="android.permission.INTERNET" /> <application android:allowBackup="true" android:icon="@drawable/tubiao" android:label="@string/app_name" android:roundIcon="@drawable/tubiao" android:supportsRtl="true" android:networkSecurityConfig="@xml/network_security_config" android:theme="@style/Theme.MyExamProject"> <activity android:name=".AddActivityActivity" android:exported="false" /> <activity android:name=".AddFurnitureActivity" android:exported="false" /> <activity android:name=".AddCaregiverActivity" android:exported="false" /> <activity android:name=".AddOldActivity" android:exported="false" /> <activity android:name=".FacilityActivity" android:exported="false" /> <activity android:name=".EventsActivity" android:exported="false" /> <activity android:name=".AddActivity2" android:exported="false" /> <activity android:name=".UpdateIFActivity" android:exported="false" /> <activity android:name=".MyIFActivity" android:exported="false" /> <activity android:name=".MainActivity" android:exported="false" /> <activity android:name=".UpdateGamesActivity" android:exported="false" /> <activity android:name=".RegisterActivity" android:exported="false" /> <activity android:name=".PersonalCenterActivity" android:exported="false" /> <activity android:name=".LoginActivity" android:exported="false" /> <activity android:name=".DeleteGamesActivity" android:exported="false" /> <activity android:name=".BackActivity" android:exported="false" /> <activity android:name=".AddGamesActivity" android:exported="false" /> <activity android:name=".HomeActivity" android:exported="true" /> <activity android:name=".WelcomeActivity" android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
03-11
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"> <!-- 记得添加下面的权限 --> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" /> <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" /> <application android:allowBackup="true" android:icon="@drawable/s2" android:label="在线书店" android:requestLegacyExternalStorage="true" android:supportsRtl="true" android:theme="@style/Theme.FlowerShop"> <activity android:name=".activity.WelcomeActivity" android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".activity.ManageActivity" android:exported="false" /> <activity android:name=".activity.StuffEditActivity" android:exported="false" /> <activity android:name=".activity.LoginActivity" android:exported="false" /> <activity android:name=".activity.RegisterActivity" android:exported="false" /> <activity android:name=".activity.MainActivity" android:exported="false" /> <activity android:name=".activity.DetailActivity" android:exported="false" /> <activity android:name=".activity.AboutActivity" android:exported="false" /> <activity android:name=".activity.InfoActivity" android:exported="false" /> <activity android:name=".activity.RecordActivity" android:exported="false" /> </application> </manifest>,我这新的项目是个书店,帮我起个新包名,指出在哪里修改。
06-03
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值