有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何知道Android中的Firestore事务是否由于外部文档修改或客户端脱机而失败?

根据firebase docs报告,在以下情况下,交易失败(仅显示与问题相关的交易):

  • When the client is offline.
  • When the transaction read a document that was modified outside of the transaction. In this case, the transaction automatically runs again. The transaction is retried a finite number of times.

但在Java中,我似乎找不到一种方法来知道我在应用程序中遇到了哪些情况。我已尝试强制转换任务异常,以查看是否有任何方法返回异常类型或任何有用的信息:

public void onComplete(@NonNull Task<Void> task) {
    ((FirebaseFirestoreException)task.getException()). // Could not find anything useful here
}

共 (0) 个答案