我可以删除Android手机编程的账户和同步? [英] Can I delete the accounts and sync in Android phone programmatically?

查看:140
本文介绍了我可以删除Android手机编程的账户和同步?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在开发的需要远程删除账户和同步,如Facebook,Twitter的,Dropbox的等等...这是可以通过编程完成的一个项目? 从你们不需要建议...

I am developing a project which needs to remotely delete the accounts and sync such as Facebook, Twitter, Dropbox and so forth... Is this possible to be done through programming? Need opinions from you guys...

感谢。

推荐答案

是的,它可以使用<一做href="http://developer.android.com/reference/android/accounts/AccountManager.html"><$c$c>AccountManager而<一href="http://developer.android.com/reference/android/accounts/AccountManager.html#removeAccount%28android.accounts.Account,%20android.accounts.AccountManagerCallback%3Cjava.lang.Boolean%3E,%20android.os.Handler%29"><$c$c>removeAccount方法。

Yes it can be done using the AccountManager and the removeAccount method.

首先得到的一个实例的AccountManager

AccountManager am = AccountManager.get(this);

然后得到设备上的所有帐户的列表:

Then get a list of all accounts on the device:

Account[] accounts = am.getAccounts();

一旦你选择了哪个帐户要删除(在这个例子中,我们将只使用第一个),调用 removeAccount 他们:

if (accounts.length > 0) {
    Account accountToRemove = accounts[0];
    am.removeAccount(accountToRemove, null, null);
}

您可以使用 removeAccount 方法的第二个参数提供一个回调函数调用一次该帐户已被删除(移除帐户是一个异步操作)。

You can use the 2nd parameter of the removeAccount method to supply a callback to be called once the account has been removed (removing an account is an asynchronous operation).

这篇关于我可以删除Android手机编程的账户和同步?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆