Firebase聊天。如何断开与服务器的连接?

时间:2017-10-01 10:12:13

标签: android firebase firebase-realtime-database

我正在使用firebase聊天。

mDatabaseReference = FirebaseDatabase.getInstance().getReference();

        mDatabaseReference.addChildEventListener(new ChildEventListener() {
            @Override
            public void onChildAdded(DataSnapshot dataSnapshot, String s) {
                try {
                    if (dataSnapshot != null && dataSnapshot.getValue() != null) {
                        Message model = dataSnapshot.getValue(Message.class);
                        mMessageList.add(model);
                        getViewState().updateRecyclerView();

                        if(mCurrentPositionVisibleLost + 1 == mMessageList.size() - 1 || mCurrentPositionVisibleLost == 0){
                            getViewState().scrollToPositionBottom();
                        }
                    }
                }catch (Throwable throwable){
                    System.out.println("Error " + throwable.getMessage());
                }

            ......

如何断开与服务器的连接?我如何登录时只上传10封邮件?

1 个答案:

答案 0 :(得分:0)

DatabaseReference.getDatabase()goOffline();