data & synchronization - manually sync mail. calender and contacts

六月ゝ 毕业季﹏ 提交于 2019-12-07 05:35:46

问题


I am trying to write an app that syncs my mail and my calender with just a single click. After looking through this forum I found some good hints and wrote a short test app that takes my first google account and starts syncing.

The code is working so far but currently only the contacts were synced!

    AccountManager am = AccountManager.get(this);
    Account[] acc = am.getAccountsByType("com.google");
    Account account = null;
    if (acc.length > 0) {
        account = acc[0];

        Bundle extras = new Bundle();
        extras.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
        extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);

        ContentResolver.requestSync(account, ContactsContract.AUTHORITY,
                extras);
    }

The method requestSync takes "authority" as parameter and now I use "ContactsContract.AUTHORITY" and I guess that is the reason for only synching my contacts. My question now is, does anybody know what authority string I have to use to only sync my mail and calender? If "null" is used as authority all three (cal, contacts and mail) get synched

public static void requestSync (Account account, String authority, Bundle extras)

Thanks in advance!!


回答1:


OK, it seems the the Authority for contacts is:

"com.android.contacts"

and for calander:

"com.android.calendar"

But I could not find the String for syncing Gmail...



来源:https://stackoverflow.com/questions/8036541/data-synchronization-manually-sync-mail-calender-and-contacts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!