开发者

How to run a sync process which updates with Google Contacts?

When I de开发者_如何学JAVAal with deleting a contact using new google api, I got the problem

here is my problem

Following is the only response :

You have to run a sync process, so it updates with Google Contacts, than it will be removed permanently. Check for deleted flag

So what should I do to run a sync process which updates with Google Contacts?


This method could resolve your probromm. but you must have set your account.

private void requestSync()
{
    AccountManager am = AccountManager.get(this);
    Account[] accounts = am.getAccounts();

    for (Account account : accounts)
    {
        int isSyncable = ContentResolver.getIsSyncable(account, ContactsContract.AUTHORITY);

        if (isSyncable > 0)
        {
            Bundle extras = new Bundle();
            extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
            ContentResolver.requestSync(accounts[0], ContactsContract.AUTHORITY, extras);
        }
    }
}


If you're trying to delete your own contact, that is, something you put into the Contacts Provider, then it won't be deleted until you sync with your own server, which should then delete the row permanently. The Contacts Provider is designed to do this, to ensure that both the server and client version of the row are deleted at the same time.

The response you got to your original question was mistaken. You don't sync with Google Contacts. You only control the sync with your own server. The Google Contacts server has its own sync adapter that's activated if the user chooses to sync with Google Contacts.

If you delete something that's being synced with Google Contacts, then it will remain "invisible" until the next sync, at which point it will be permanently removed. The Contacts Provider will automatically act as if the thing doesn't exist. If you're seeing it, it means that you're doing something incorrectly in the Contacts Provider. There may be a row attached to the contact you're seeing that's not been deleted correctly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜