1
プライベートダイアログでテキストメッセージを送信しようとしていますが、プライベートダイアログを作成するまでは問題なく動作しますが、 nullのオブジェクト参照の '無効com.quickblox.chat.QBAbstractChat.sendMessage(com.quickblox.chat.model.QBChatMessage)' は」QUICKBLOX nullオブジェクト参照で仮想メソッドsendMessageを呼び出そうとしました
@Override
protected void onCreate(Bundle savedInstanceState) {
final Context context = this;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
QBSettings.getInstance().init(getApplicationContext(), APP_ID, AUTH_KEY, AUTH_SECRET);
QBSettings.getInstance().setAccountKey(ACCOUNT_KEY);
QBChatService.setDebugEnabled(true);
final QBChatService chatService = QBChatService.getInstance();
final QBUser qbUser = new QBUser("shahzeb", "shahzeb143");
QBAuth.createSession(qbUser).performAsync(new QBEntityCallback<QBSession>() {
@Override
public void onSuccess(QBSession qbSession, Bundle bundle) {
qbUser.setId(qbSession.getUserId());
chatService.login(qbUser, new QBEntityCallback() {
@Override
public void onSuccess(Object o, Bundle bundle) {
final QBChatDialog dialog = DialogUtils.buildPrivateDialog(25024405);
QBRestChatService.createChatDialog(dialog).performAsync(new QBEntityCallback<QBChatDialog>() {
@Override
public void onSuccess(QBChatDialog qbChatDialog, Bundle bundle) {
QBChatMessage chatMessage = new QBChatMessage();
chatMessage.setSenderId(qbUser.getId());
chatMessage.setBody("Hi there!");
try {
dialog.sendMessage(chatMessage);
} catch (SmackException.NotConnectedException e) {
e.printStackTrace();
}
}
@Override
public void onError(QBResponseException e) {
}
});
}
@Override
public void onError(QBResponseException e) {
}
});
}
@Override
public void onError(QBResponseException e) {
}
});
}
}