创建 QBPrivateChat 管理器在 android 中获取错误空指针

Create QBPrivateChatManager getting error nullpointer in android

创建 Quickblox 聊天但创建对话时获取空指针。

QBPrivateChatManager privateChatManager = QBChatService.getInstance().getPrivateChatManager();
            privateChatManager.createDialog(sub_arr.get(position).getOccupentId(), new QBEntityCallbackImpl<QBDialog>() {
                @Override
                public void onSuccess(QBDialog dialog, Bundle args) {
                     Log.d("dialog1", dialog+"");
                }

                @Override
                public void onError(List<String> errors) {

                }
            });

如果你没有打电话

QBChatService.getInstance().login(qbUser);

然后下一行将返回 null:

QBPrivateChatManager privateChatManager = QBChatService.getInstance().getPrivateChatManager();

所以正确的方法是登录聊天,然后获取QBPrivateChatManager