【问题标题】:List supported authorites for selected accounts列出所选帐户支持的授权
【发布时间】:2012-07-24 15:39:01
【问题描述】:

我正在尝试开发一个使用ContentResolver.requestSync(account, authority, extras); 仅同步选定帐户的应用程序。

我能够分别使用com.android.contactscom.android.calendar 作为authority同步 联系人和日历。

但是,有没有办法获得特定帐户支持的权限列表

还有,用nullauthority有什么效果?

【问题讨论】:

    标签: android sync android-contentresolver accounts


    【解决方案1】:

    使用getSyncAdapterTypes() 获取有关系统已知的SyncAdapters 的信息。

    SyncAdapterType[] types = ContentResolver.getSyncAdapterTypes();
    for (SyncAdapterType type : types) {
        if (yourAccount.type.equals(type.accountType)) {
            boolean isSyncable = ContentResolver.getIsSyncable(yourAccount, type.authority) > 0;
            if (isSyncable) {
                ContentResolver.requestSync(yourAccount, type.authority, extras);
            }
        }
    }
    

    不要忘记getIsSyncable() 方法需要READ_SYNC_SETTINGS 权限。

    【讨论】:

    • Thankz @biegleux .. 它的工作.. 但是,它没有授权同步电子邮件.. 任何想法??
    猜你喜欢
    • 1970-01-01
    • 2019-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多