Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何正确解决android azure同步期间的冲突?_Android_Azure - Fatal编程技术网

如何正确解决android azure同步期间的冲突?

如何正确解决android azure同步期间的冲突?,android,azure,Android,Azure,我在azure同步方面遇到了麻烦,我能够通过mCLient.getSyncContext.getPendingOperations检测到挂起操作的数量;但无法解决这些问题。有任何帮助或建议吗?在脱机情况下使用时,如果您有挂起的操作,可以使用推送功能将它们推送到服务器 它看起来类似于以下内容: try { MobileServiceSyncContext syncContext = mClient.getSyncContext(); syncContext.push().get()

我在azure同步方面遇到了麻烦,我能够通过mCLient.getSyncContext.getPendingOperations检测到挂起操作的数量;但无法解决这些问题。有任何帮助或建议吗?

在脱机情况下使用时,如果您有挂起的操作,可以使用推送功能将它们推送到服务器

它看起来类似于以下内容:

try {
    MobileServiceSyncContext syncContext = mClient.getSyncContext();
    syncContext.push().get();

    // here you would do a pull on any table you want to grab data from
}
catch (final MobileServiceConflictException e)
{
    // the server item causing the exception can be obtained by calling e.getItem()
    JsonObject serverObject = e.getItem();

    // on the sync context, call one of the following:

    // .cancelAndDiscardItem() to cancel update and discard local item

    // .cancelAndUpdateItem() to update the local item with the server's copy

    // .cancelAndUpdateItem(JsonObject item) to update the server's item w/ the local

    // make sure to call push() again on the sync context
}

总而言之-确保在MobileServiceSyncContext上调用push,然后处理可能返回的任何MobileServiceConflictException。

如果我捕获MobileServiceConflictException,android studio会告诉我,该异常从未在相应的try块中抛出

try {
                        MobileServiceSyncContext syncContext = mClient.getSyncContext();
                        syncContext.push().get();

                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    } catch (ExecutionException e) {
                        e.printStackTrace();
                    } catch (MobileServiceConflictException e) {

                    }

谢谢你的回答,我的错误是我在其他类型的异常中查找项目。对我来说,android studio也不允许添加此捕获。