2番目の質問に答えるには:
パッケージ名がcom.companynameであると仮定します
パッケージcom.companyname.authにAbstractAccountAuthenticatorを拡張するAuthenticatorクラスを作成し、このメソッドを実装します。
@Override
public Bundle getAccountRemovalAllowed(AccountAuthenticatorResponse response, Account account) {
Bundle result = new Bundle();
boolean allowed = false; // or whatever logic you want here
result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, allowed);
return result;
}
これをマニフェストに追加します。
<service android:name=".auth.AuthenticationService">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator"></action>
</intent-filter>
<meta-data android:name="android.accounts.AccountAuthenticator" android:resource="@xml/authenticator"></meta-data>
</service>
(lintは、このエクスポートされたサービスに権限が必要ないことを警告することに注意してください)。
次に、res/xmlにauthenticator.xmlファイルを追加します。
<?xml version="1.0" encoding="utf-8"?>
<account-authenticator
xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="com.companyname"
android:icon="@drawable/app_icon"
android:smallIcon="@drawable/app_icon_small"
android:label="@string/app_name" />
アカウントの種類が「com.companyname」であると仮定します。これが私たちの仕事であり、API8以降で機能しているようです。