小编Pra*_*nna的帖子

当用户玩快速游戏时,如何确定谁是第一个玩家?

我正在使用以下代码onRoomConnected(int statusCode, Room room)来决定谁是第一个玩家.但有时候我两个球员的得分都是第一/第二.如何解决此错误.

        if (quickGame) {
            myTurn = room.getParticipants().get(0).getParticipantId().equals(myId);
        } else {
            myTurn = room.getCreatorId().equals(myId);
        }
        if (myTurn) {
            Log.e(TAG, "First Player");
            status.setText("Click a button to start");
        } else {
            Log.e(TAG, "Second Player");
            status.setText("Wait for opponent to start");
        }
Run Code Online (Sandbox Code Playgroud)

google-play-games

7
推荐指数
1
解决办法
1240
查看次数

Firestore - 如何从 Android 更新其键中包含句点(.)的字段?

更新包含句点 (.) 的字段未按预期工作。在文档中,可以通过提供点分隔的字段路径字符串或提供 FieldPath 对象来更新嵌套字段。因此,如果我有一个字段,关键是"com.example.android"如何更新此字段(来自 Android)?

在我的场景中,如果文档不存在,我必须设置它,否则更新文档。因此,第一组是创建包含句点的字段,然后尝试更新相同的字段,因为它包含句点,因此使用嵌套字段创建新字段。

db.collection(id).document(uid).update(pkg, score)
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

android firebase google-cloud-firestore

5
推荐指数
2
解决办法
2530
查看次数

firestore 操作超时

如何设置firestore读、写、更新等操作的超时时间?因为当连接不存在时..它不会触发OnCompleteListener

firebase google-cloud-firestore

5
推荐指数
1
解决办法
8323
查看次数