32
<meta-data android:name="android.accounts.AccountAuthenticator"
33
android:resource="@xml/authenticator" />
Finally, the res/xml/authenticator.xml configuration file (which is value of the
android:resourceattribute above) should have an element named account-authenticator where
value ofandroid:accountType attribute is set to com.jquerymobile.demo.contact. Note that this is
value of theaccountType in ContactsActivity. Summarizing the discussion, first look at the
highlighted section inAndroidManifest.xml.
这 里 , 用
android:resource 的 值 , 指 出 了 要 在 res/xml 下 配 置 一 个 验 证 配 置 文 件
authenticator.xml,文件如下:
34
<?xml
version="1.0"
encoding="utf-8"?>
<account-authenticator
xmlns:android="http://schemas.android.com/apk/res/android"
35
android:accountType="com.jquerymobile.demo.contact"
android:icon="@drawable/icon"
36
android:smallIcon="@drawable/icon" android:label="@string/app_name"
37
/>
其 中 的
android:accountType 指 出 了 要 验 证 的 帐 号 的 实 体 类 为
com.jquerymobile.demo.contact。最后我们综合看下修改后的 AndroidManifest.xml 如下:
38
<?xml
version="1.0"
encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
39
package="com.jquerymobile.demo.contact" android:versionCode="1"
40
android:versionName="1.0">
<uses-permission
android:name="android.permission.READ_CONTACTS"/>
41
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
42
<uses-permission
android:name="android.permission.AUTHENTICATE_ACCOUNTS" /> <application
android:debuggable="true" android:icon="@drawable/icon"
43
android:label="@string/app_name"> <service
44
android:name=".authentication.AuthenticationService"
android:exported="true">
45
<intent-filter>
<action
android:name="android.accounts.AccountAuthenticator" />
46
</intent-filter>
<meta-data
android:name="android.accounts.AccountAuthenticator"
47
android:resource="@xml/authenticator" /> </service>
48
<activity
android:name=".ContactsActivity"
android:configChanges="orientation|keyboardHidden"
49
android:label="@string/app_name"> <intent-filter>
50
<action android:name="android.intent.action.MAIN" /> <category