如何显示同步失败的消息

nik*_*min 3 android sync contactscontract android-syncadapter android-contacts

我已经构建了一个联系人同步适配器.这一切都很好,但我还需要一件事.如果由于某种原因导致同步无法成功完成,我希望在同步失败时显示Google帐户显示的消息

截图

nik*_*min 7

解决方案是设置同步结果的延迟.在此延迟之后,将重新启动同步.

try {
    DO THE SYNCHRONIZATION
} catch (AuthenticationException e) {
    Log.e(TAG, "AuthenticationException");
    syncResult.stats.numAuthExceptions++;
    syncResult.delayUntil = 180;
} catch (ParseException e) {
    Log.e(TAG, "ParseException");
    syncResult.stats.numParseExceptions++;
} catch (IOException e) {
    Log.e(TAG, "IOException");
    syncResult.stats.numIoExceptions++;
    syncResult.delayUntil = 180;
}
Run Code Online (Sandbox Code Playgroud)

  • 这也将显示具体信息? (3认同)