为什么我的听众在此Firestore中没有被击中 [英] Why is not the my listeners hit here in this Firestore set
问题描述
我有一个奇怪的地方,OnSuccessListener
或OnFailureListener
不再被调用.一切正常,但是当我打开移动数据并呼叫OnSuccessListener
或OnFailureListener
以外的Wifi时.
I have this strange thing where OnSuccessListener
or OnFailureListener
stopped being called. Everything works ok but when I turn of mobile data and Wifi non of the OnSuccessListener
or OnFailureListener
is being called.
如果我在下面的代码ref.set(update).....
上放置一个断点,则确实会命中断点,但OnSuccessListener
或OnFailureListener
不会触发
If I put a breakpoints on the below code ref.set(update).....
the breakpoints are indeed hit but non of the OnSuccessListener
or OnFailureListener
fires
Map<String, String> update = new HashMap<>();
update.put(ByteData.DATA, data);
DocumentReference ref = firestore
.collection(DEVICE_DATA)
.document(FirestoreManager.getInstance().getUserId())
.collection(DEVICE_DATA_STREAM)
.document(batteryEntity.getEntityId());
ref.set(update).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
// do some stuff
}
}).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
// do some stuff
}
});
推荐答案
当我打开移动数据并使用Wifi上网时[c0>或
OnFailureListener
都没有被调用
这是预期的行为.仅当数据已写入服务器(或被服务器拒绝)后,才会调用完成侦听器.
That is the expected behavior. The completion listeners are only called once the data has been written on (or rejected by) the server.
监听器不会为本地写入操作触发.如果本地写操作失败,则客户端将引发常规异常.
The listener doesn't fire for local write operation. If the local write operation were to fail, the client will raise a regular exception.
这篇关于为什么我的听众在此Firestore中没有被击中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!