Android:如何从“帐户和同步”下显示的数据库中删除帐户来自我自己的申请
如何从“帐户和同步”中删除 Google 帐户?我试图将此行称为我的应用程序:
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();
}
}
这段代码没有做任何事情。我觉得正在抛出异常,这是在较低层处理的。
How can I delete google accounts from "accounts and sync"? I'm trying to call this line my app:
AccountManagerService.getSingleton().onServiceChanged(null,true);
whereas onServiceChanged() method is defined in 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();
}
}
This piece of code is not doing anything. I feel exception is being thrown which is handled at lower layer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试 AccountManager.removeAccount。
Try AccountManager.removeAccount.