I link to the official website https://quickblox.com/developers/Android#Download_Android_SDK
gradle compile successfully:
repositories {
maven {
url "https://github.com/QuickBlox/quickblox-android-sdk-releases/raw/master/"
}
}
dependencies {
compile "com.quickblox:quickblox-android-sdk-core:2.5.1@aar"
compile("com.quickblox:quickblox-android-sdk-chat:2.5.1@aar") {
transitive=true
}
}
then I use the code first:
I had APP_ID ... etc.
QBSettings.getInstance().init(getApplicationContext(), APP_ID, AUTH_KEY, AUTH_SECRET);
QBSettings.getInstance().setAccountKey(ACCOUNT_KEY);
Second step: I refer to the Guide: Getting started with the chat API https://quickblox.com/developers/Android_XMPP_Chat_Sample#Guide:_Getting_Started_with_Chat_API
//Prepare chat service
QBChatService.setDebugEnabled(true); // enable chat logging
QBChatService.setDefaultPacketReplyTimeout(10000);//set reply timeout in milliseconds for connection packet.
//Can be used for events like login, join to dialog to increase waiting response time from server if network is slow.
//configure chat socket
QBChatService.ConfigurationBuilder chatServiceConfigurationBuilder = new QBChatService.ConfigurationBuilder();
chatServiceConfigurationBuilder.setSocketTimeout(60); //Sets chat socket read timeout in seconds
chatServiceConfigurationBuilder.setKeepAlive(true); //Sets connection socket keepAlive option.
chatServiceConfigurationBuilder.setUseTls(true); //Sets the TLS security mode used when making the connection. By default TLS is disabled.
QBChatService.setConfigurationBuilder (chatServiceConfigurationBuilder);
I have a problem that I cannot import QBChatService.ConfigurationBuilder
so I'm trying to change gradle tocompile("com.quickblox:quickblox-android-sdk-chat:2.6.1")
now QBChatService.ConfigurationBuilder can be imported
Third step: I take the official step using the code:
final QBChatService chatService = QBChatService.getInstance();
final QBUser user = new QBUser("garrysantos", "garrysantospass");
QBAuth.createSession(user, new QBEntityCallback<QBSession>() {
@Override
public void onSuccess(QBSession qbSession, Bundle bundle) {
user.setId(qbSession.getUserId());
chatService.login(user, new QBEntityCallback() {
@Override
public void onSuccess(Object o, Bundle bundle) {
}
@Override
public void onError(QBResponseException e) {
}
});
}
@Override
public void onError(QBResponseException e) {
}
});
ConnectionListener connectionListener = new ConnectionListener() {
@Override
public void connected(XMPPConnection xmppConnection) {
}
@Override
public void authenticated(XMPPConnection xmppConnection, boolean b) {
}
@Override
public void connectionClosed() {
}
@Override
public void connectionClosedOnError(Exception e) {
}
@Override
public void reconnectionSuccessful() {
}
@Override
public void reconnectingIn(int i) {
}
@Override
public void reconnectionFailed(Exception e) {
}
};
QBChatService.getInstance().addConnectionListener(connectionListener);
boolean isLoggedIn = chatService.isLoggedIn();
if (!isLoggedIn) {
return;
}
chatService.logout(new QBEntityCallback<Void>() {
@Override
public void onSuccess(Void aVoid, Bundle bundle) {
chatService.destroy();
}
@Override
public void onError(QBResponseException e) {
}
});
QBChatService.getInstance().setReconnectionAllowed(false);
QBChatDialog, ....
ArrayList<Integer> occupantIdsList = new ArrayList<Integer>();
occupantIdsList.add(34);
occupantIdsList.add(17);
QBChatDialog dialog = new QBChatDialog();
dialog.setName("Chat with Garry and John");
dialog.setPhoto("1786");
dialog.setType(QBDialogType.GROUP);
dialog.setOccupantsIds(occupantIdsList);
QBChatDialog dialog = DialogUtils.buildDialog("Chat with Garry and John", QBDialogType.GROUP, occupantIdsList);
QBRestChatService.createChatDialog(dialog).performAsync(new QBEntityCallback<QBChatDialog>() {
@Override
public void onSuccess(QBChatDialog result, Bundle params) {
}
@Override
public void onError(QBResponseException responseException) {
}
});
gradle compile compile("com.quickblox:quickblox-android-sdk-chat:3.3.0")
QBChatDialog .
...
Can't not resolve symbol 'QBSettings' and 'QBSession'
, ?
?
... ?
- , , !
@Jagapathi, , , ,
, :
private void setupQuickBlox() {
QBSettings.getInstance().init(getApplicationContext(), APP_ID, AUTH_KEY, AUTH_SECRET);
QBSettings.getInstance().setAccountKey(ACCOUNT_KEY);
QBSettings.getInstance().setAutoCreateSession(true);
String enterAccount = editAccount.getText().toString();
String enterPassword = editPassword.getText().toString();
Log.d(TAG,enterAccount);
Log.d(TAG,enterPassword);
final QBUser user = new QBUser(enterAccount, enterPassword);
QBUsers.signIn(user).performAsync(new QBEntityCallback<QBUser>() {
@Override
public void onSuccess(QBUser qbUser, Bundle bundle) {
SharedPreferences.Editor s = getSharedPreferences("QBid", 0).edit();
s.putString("id", user.getId().toString());
s.apply();
Log.d(TAG,user.getId().toString());
Toast.makeText(MainActivity.this, "Login success with quickblox", Toast.LENGTH_SHORT).show();
}
@Override
public void onError(QBResponseException e) {
Toast.makeText(MainActivity.this, "Login error", Toast.LENGTH_SHORT).show();
}
});
}
onCreat, , , , , ? , , , user.getId().toString() , ?
, :


:
static final String APP_ID = "50427";
static final String AUTH_KEY = "naMGFKMshdLC3s4";
static final String AUTH_SECRET = "GP8ey4GsQXt2TGu";
static final String ACCOUNT_KEY = "dHYgix3we3bxxsvMqyuR";
:


onClcik:
buttonLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
setupQuickBlox();
}
});
:

