的是Android:出口="真"确有必要的身份验证服务? [英] Is android:exported="true" really necessary for an authentication service?

查看:109
本文介绍了的是Android:出口="真"确有必要的身份验证服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有通常参与实施一个Android认证两个服务 - 验证服务来回报的认证,并同步服务提供了一个同步适配器。这个问题是专门关于身份验证服务,虽然在最例子两个服务被赋予的android:出口=真正的的Andr​​oidManifest.xml ,例如属性:

There are usually two services involved with implementing an Android authenticator - the Authentication service to return an authenticator, and the Sync service which provides a sync adapter. This question is specifically about the Authentication service, although in most examples both services are given the android:exported="true" attribute in the AndroidManifest.xml, eg:

<service
    android:name=".authenticator.AuthenticationService"
    android:exported="true">
    <intent-filter>
        <action
            android:name="android.accounts.AccountAuthenticator" />
    </intent-filter>
    <meta-data
        android:name="android.accounts.AccountAuthenticator"
        android:resource="@xml/authenticator" />
</service>

从验证服务中删除属性似乎没有任何效果(测试升级Froyo,姜饼) - 在auth code继续就好了工作 - 所以实际上是必需的标志

Removing the attribute from the Authentication service seems to have no effect (tested Froyo, Gingerbread) - the auth code continues to work just fine - so is the flag actually necessary?

推荐答案

好吧,通过阅读文档中,<一个回答这个自己href=\"http://developer.android.com/guide/topics/manifest/service-element.html#exported\">documentation为导出属性说道:

Ok, to answer this myself by reading the docs, the documentation for the exported attribute says:

默认值取决于服务是否包含意图
  过滤器。由于没有任何过滤器的装置,它只能被调用
  通过指定确切的类名。这意味着,该服务是
  仅用于应用程序内部使用(因为别人不会
  知道类名)。因此,在这种情况下,默认值是假。
  另一方面,至少一个过滤器的presence意味着
  该服务是用于外部使用的,所以默认值是
  真。

The default value depends on whether the service contains intent filters. The absence of any filters means that it can be invoked only by specifying its exact class name. This implies that the service is intended only for application-internal use (since others would not know the class name). So in this case, the default value is "false". On the other hand, the presence of at least one filter implies that the service is intended for external use, so the default value is "true".

所有的认证服务有一个意图过滤器 - 的文档的<一个href=\"http://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator.html\">AbstractAccountAuthenticator说:

All Authentication services have an intent filter - the docs for AbstractAccountAuthenticator say:

为了成为一个认证必须...写信服务,
  返回getIBinder()的结果在服务的
  当与行动意图调用onBind(android.content.Intent)
  ACTION_AUTHENTICATOR_INTENT。

In order to be an authenticator one must ... write a service that returns the result of getIBinder() in the service's onBind(android.content.Intent) when invoked with an intent with action ACTION_AUTHENTICATOR_INTENT.

这需要一个意图过滤器,从而远销该服务的默认值真正。所以,这个问题的答案是的不,属性的不可以必需的 - 因为它默认为true。

This requires an intent filter, consequently the default value of exported for the service is true. So the answer to this question is "No, the attribute is not necessary - because it's true by default".

这篇关于的是Android:出口=&QUOT;真&QUOT;确有必要的身份验证服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆