Android 导出的服务不需要许可:这是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10474134/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Exported service does not require permission: what does it mean?
提问by enzom83
I created a service that is bound by other applications through AIDL, and I add it to the manifest as follows:
我创建了一个通过AIDL绑定其他应用的服务,我把它添加到manifest中,如下:
<service android:name=".MyService">
<intent-filter>
<action android:name="org.example.android.myservicedemo.IService" />
</intent-filter>
</service>
where IService is the AIDL interface.
其中 IService 是 AIDL 接口。
In this way, Eclipse show me the warning Exported service does not require permission. If I remove the intent-filter
, the warning disappear, but obviously the applications are unable to bind to the service.
这样,Eclipse 会向我显示警告Exported service does not require permission。如果我删除intent-filter
,警告消失,但显然应用程序无法绑定到服务。
What does this warning mean?
这个警告是什么意思?
回答by Nam Vu
I had the same issue when I updated SDKto version 20. I removed it adding android:exportedproperty android:exported="false"
like so:
当我将 SDK 更新到版本20时,我遇到了同样的问题。我删除了它添加android:exported属性, android:exported="false"
如下所示:
<service android:name=".MyService"
android:exported="false">
<intent-filter>
<action android:name="org.example.android.myservicedemo.IService" />
</intent-filter>
</service>
See this doc
请参阅此文档
回答by Snicolas
If you want to restrict you activity usage to your own application, then you should add exported=false
to your activity's manifest statement.
如果您想将您的活动使用限制在您自己的应用程序中,那么您应该添加exported=false
到您的活动的清单声明中。
If you want to allow other applications to use it (explicitly through its class name or, better, by using an intent with a data type or action) then you have two choices :
如果您想允许其他应用程序使用它(明确通过其类名,或者更好地,通过使用具有数据类型或操作的意图),那么您有两种选择:
- restrict those applications by using a permission
- allow all applications to use it, then you can add
tools:ignore="ExportedActivity"
to your activity's manifest statement.
- 通过使用权限限制这些应用程序
- 允许所有应用程序使用它,然后您可以添加
tools:ignore="ExportedActivity"
到您的活动的清单声明。
--
——
Same reasonning applies to a service, with tools:ignore="ExportedService"
and content providers with tools:ignore="ExportedContentProvider"
.
相同的推理适用于tools:ignore="ExportedService"
具有tools:ignore="ExportedContentProvider"
.