【发布时间】:2018-06-27 07:53:12
【问题描述】:
错误
原因:java.lang.SecurityException: uid 10184 cannot get secrets 对于以下类型的帐户:
代码
@Nullable
public static Account getSyncAccount(Context context)
{
AccountManager accountManager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);
Account newAccount = new Account(context.getString(R.string.app_name), context.getString(R.string.content_authority));
assert accountManager != null;
if(null == accountManager.getPassword(newAccount))
{
if(!accountManager.addAccountExplicitly(newAccount,"",null)) //Error here
{
return null;
}
onAccountCreated(newAccount,context);
}
return newAccount;
}
身份验证器服务
<service android:name=".sync.ProductAuthenticatorService">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator"/>
</intent-filter>
<meta-data android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator"/>
</service>
<!-- Sync Adapter Service -->
<service android:name=".sync.ProductSyncService"
android:exported="true"
>
<intent-filter>
<action android:name="android.content.SyncAdapter"/>
</intent-filter>
<meta-data android:name="android.content.SyncAdapter"
android:resource="@xml/syncadapter"/>
</service>
【问题讨论】:
-
请添加一些解释,您要达到什么目的以及问题所在。
标签: android android-syncadapter securityexception