重新在android系统initate同步适配器 [英] Re initate Sync adapter in android

查看:366
本文介绍了重新在android系统initate同步适配器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能在我的手机成功地创建同步适配器,但我不能够处理一个特定的场景。

I'm able to successfully create Sync adapter in my phone, but i'm not able to handle a particular scenario.

我的任务同步的应用程序,要求任务的权限来获取任务或适用于获得许可从谷歌服务器上的任何服务。这种情况下发生的第一次,如果用户转移到谷歌帐户,而无需启动应用程序。

My task sync app, requires the tasks permission to fetch tasks or it applicable for getting permission for any service from Google server. this scenario occurs for the first time, if the user moves to Google account without launching the application.

1)进入设置 - >帐户和同步 - >选择一个谷歌帐户,

1) Go to Settings --> Accounts and sync --> Choose a Google account,

2)有任务同步内容提供商将是present。

2) there the tasks sync content provider will be present.

3)一旦我美元同步p $ PSS,因为首次同步提供者没有获得任务或任何谷歌服务等。占它提出userRecoverableException

3) Once i press on Sync, since for the first time the sync provider do not have access to Tasks or any Google services etc.. accounts it raises userRecoverableException

4),并发出通知供应商的帮助下,我将在我的catch块养推送通知。

4) With help of Notification provider i will raise a push notification in my catch block.

在这里,我怎么做的,e是userRecoverableException意图。

Here how i'm doing, e is the userRecoverableException intent.

PendingIntent pendingNotificationIntent = PendingIntent.getActivity(
                        mContext, constants.REQUEST_AUTHORIZATION, e.getIntent(),
                        PendingIntent.FLAG_UPDATE_CURRENT
                        | PendingIntent.FLAG_ONE_SHOT); 

4)一旦用户点击它通知将打开一个验证窗口,用户同意为您的应用程序来获取日历,联系人,任务等服务的许可。

4) once user click on notification it will open a authentication window, user approves permission for your app to fetch calender, contacts, task etc service.

5)现在如何重新一旦用户完成身份验证部分启动同步?此外,我注意到一些应用程序旁边会显示同步图标红色图标感叹,称同步正在经历的问题,将在短时间内恢复。一旦他们获得许可,他们会自动将恢复和同步。

5) Now how to re initiate the sync once user completes the authentication part?. Also i notice some app shows a red color exclamatory icon next to sync icon, saying "sync is experiencing problems it will be back shortly". Once they get permission automatically they will resume and sync.

下面如何获得通知重新启动同步或立即恢复为验证用户权限

Here how to get notification to restart sync or resume as soon as user authenticate the permission

推荐答案

下面是解决方案,

我们需要使用syncResult.stats.numAuthExceptions讲述例外,它会自动抛出消息。 syncResult.delayUntil拭目以待经过的时间重启后同步

we need to use the syncResult.stats.numAuthExceptions to tell about exception, it throws message automatically. syncResult.delayUntil will wait and restart sync after elapsing time

如何显示

这篇关于重新在android系统initate同步适配器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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