如何从“帐户和同步”中删除谷歌帐户?我正在尝试将此行称为我的应用程序:
AccountManagerService.getSingleton().onServiceChanged(null,true);
而 onServiceChanged() 方法是在 AccountManagerService.java 中定义的。
public void onServiceChanged(AuthenticatorDescription desc, boolean removed) {
boolean accountDeleted = false;
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
Cursor cursor = db.query(TABLE_ACCOUNTS,
new String[]{ACCOUNTS_ID, ACCOUNTS_TYPE, ACCOUNTS_NAME},
ACCOUNTS_TYPE + "=?", new String[]{desc.type}, null, null, null);
try {
while (cursor.moveToNext()) {
final long accountId = cursor.getLong(0);
final String accountType = cursor.getString(1);
final String accountName = cursor.getString(2);
Log.d(TAG, "deleting account " + accountName + " because type "
+ accountType + " no longer has a registered authenticator");
db.delete(TABLE_ACCOUNTS, ACCOUNTS_ID + "=" + accountId, null);
accountDeleted = true;
}
} finally {
cursor.close();
if (accountDeleted) {
sendAccountsChangedBroadcast();
}
}
这段代码没有做任何事情。我觉得正在抛出异常,这是在较低层处理的。