Ask tech team
From QuickBlox Developers (API docs, code samples, SDK)
Jump to: navigation, search


Code samples

Run samples on IDEA IDE

Go to menu File - Import Project. Select path to sample, select Import project from external model, select Gradle, select Use default gradle wrapper(recommended) and click OK.

Go to menu File - Import Project. Select path to sample, select Create project from existing sources, click some times Next and Finish.

Run samples on Android Studio

Go to menu File - Import Project. Select path to sample, select Use default gradle wrapper(recommended) and click OK.

How to change gradle version

To change gradle version you need to:

  • set version of plugin in <quickblox-android-sdk>/build.gradle
classpath ''
  • set version of wrapper in <quickblox-android-sdk>/gradle/wrapper/

Run samples on Eclipse IDE

Go to menu File - New - Project. Select Android Project from Existing Code and Browse to your project-directory, click Finish.

Run samples on Terminal

Go to project-directory and perform:

 $ gradle installDebug

Start sample on your device.


Learn how to enable Push Notifications, create a Chat room, authenticate users via Facebook, show users' locations and POIs, store and retrieve files from the cloud - these code samples are really simple so that even beginner developers can understand:

Title APIs used Description
Android video chat sample Chat, Users This shows the Android video chat SDK in action. The sample demonstrates video (or voice) calling between two users.

Simple Android Chat code sample Chat, Users The Chat sample connects and socializes your users with the chat module. Features include: Peer to Peer Chat; Group chat; Location based chat; Push notification for offline users.

Simple Android Location code sample Location The Location sample connects app users with each other and their environment. Using GPS locations, map integrations and local data, end users can literally 'see' each other on the map and engage with other users

Simple Android Push Notifications (Messages) code sample Messages, Users Push notifications to your user base — even when your app is not running! This sample enables you to send notifications and alerts to users at any time through an API or easy-to-use admin panel. You can filter who you send messages to through additional parameters.

Simple android Custom Objects (key value data store) code sample Сustom Objects This Custom Objects sample allows to create any server side data structure, use it as you want, create any logic and a lot of others custom features.

Simple android Users authentication code sample Users The Users sample helps you manage and retain your user base across all platforms. It includes a simple authentication process with Single Sign-On and integration across all popular platforms.

Simple android leaderboard / high scores / star ratings code sample Ratings High scores, leaderboards and star ratings — all made easy with Ratings sample. Create an interactive ranking element to your app with this sample, highlight users results, show nearest competitors.

Simple android content storage and update code sample Content The Content sample allows send, stream, store, share and save content, update your app's content without having to republish.

How to: add SDK to IDE and connect to the cloud

Import jar file(quickblox-android-sdk/jar/quickblox-android.jar) to your project.

QuickBlox Android SDK uses next libs:

  • qb-gson-2.2.1.jar
  • httpclient-4.2.1.jar
  • httpcore-4.2.2.jar
  • httpmime-4.2.1.jar
  • javabase64-1.3.1.jar
  • simple-xml-2.6.7.jar

Oh, please, please show me the code

Android SDK is really simple to use. In just a few minutes you can power up your mobile app with huge amount of awesome communication features & data services.

The common way to interact with QuickBlox can be presented with the following sequence of actions:

  1. Initialize framework with application credentials
  2. Create session
  3. Login with existing user or register new one
  4. Perform actions with QuickBlox communication services and any data entities (users, locations, files, custom objects, pushes etc.)

Initialize framework with application credentials

QBSettings.getInstance().fastConfigInit("961", "PBZxXW3WgGZtFZv", "vvHjRbVFF6mmeyJ");

A couple of words about Authentication and Authorization

To be able to use QuickBlox API you have to create a session.

There are 2 types of session:

  • Application session. It provides only READ access to data.
  • User session. It provides CRUD(Create, Read, Update, Delete) access to data.

To create an application session use this code:

QBAuth.createSession(new QBCallbackImpl() {
    public void onComplete(Result result) {
        // result comes here
        // check if result success
        if (result.isSuccess()) {
            // do stuff you need

With an Application session you can READ any data you need and only have to do one Create operation - User Sign Up:

final QBUser user = new QBUser("indianajones", "indianapassword");
// register user
QBUsers.signUp(user, new QBCallbackImpl() {
    public void onComplete(Result result) {
        // result comes here
        // check if result success
        if (result.isSuccess()) {
            // do stuff you need

To update an Application session to a User session you have to login to QuickBlox:

// authorize user
QBUsers.signIn("indianajones", "indianapassword", new QBCallbackImpl() {
    public void onComplete(Result result) {
        // result comes here
        // check if result success
        if (result.isSuccess()) {
            // do stuff you need

Login to Chat

// initialize SMACK
final QBUser user = new QBUser("indianajones", "indianapassword");
// login to Chat
QBChatService.getInstance().loginWithUser(user, new SessionCallback() {
    public void onLoginSuccess() {
        Log.d(TAG, "success when login");
    public void onLoginError(String error) {
        Log.e(TAG, "error when login");

Performing actions

Send Chat message

// Create 1-1 chat
QBPrivateChat chat = QBChatService.getInstance().createChat();
chat.addChatMessageListener(new ChatMessageListener() {
    public void processMessage(Message message) {
        Log.d(TAG, "Messags: " + message.getBody());
    public boolean accept(Message.Type type) {
        switch (messageType) {
            case chat: 
                return true; // process 1-1 chat messages
                return false;
// send message    
chat.sendMessage(546, "Hi mate!");

Creating a new location for Indiana Jones

QBLocation location = new QBLocation(23.2344, -12.23523, "Hello, world, I'm Indiana Jones, I'm at London right now!";
QBLocations.createLocation(location, new QBCallbackImpl() {
    public void onComplete(Result result) {
        // Check-in result
        if (result.isSuccess()) {
            QBLocationResult locationResult = (QBLocationResult) result;
            Log.d(TAG, "Your checkin: " + locationResult.getLocation());
        } else {
            Log.e(TAG, "Errors: " + result.getErrors());

To put an Image into storage

// Upload file to Content module
File image = new File("path to image");
QBContent.uploadFileTask(image, false, new QBCallbackImpl() {
    public void onComplete(Result result) {
        if (result.isSuccess()) {
            // Success, do something

Android Framework provides the following classes to interact with QuickBlox API (each class has suite of static methods):

  1. QBAuth
  2. QBUsers
  3. QBChatService
  4. QBCustomObjects
  5. QBLocations
  6. QBContent
  7. QBRatings
  8. QBMessages

Performing actions with context

It's possible to perform any request to REST API with some context. Context helps you to detect a result's source.

For example, let's create 2 location checkins and detect each result:

// 1st checkin
QBLocation location = new QBLocation(23.2344, -12.23523, "Hello, world, This is checkin number 1");
QBLocations.createLocation(location, this, "checkin1");
// 2nd checkin
location = new QBLocation(3.2344, 22.23523, "Hello, world, This is checkin number 2");
QBLocations.createLocation(location, this, "checkin2");
public void onComplete(Result result, Object context) {
    if (result.isSuccess()) {
        QBLocationResult locationResult = (QBLocationResult) result;
        String contextStr = (String) context;
        if (contextStr.equals("checkin1")) {
            Log.d(TAG, "This is checkin 1: " + locationResult.getLocation());
        } else {
            Log.d(TAG, "This is checkin 2: " + locationResult.getLocation());
public void onComplete(Result result) {

Read on: Android SDK documentation (Javadoc)

Full reference on classes and protocols used in QuickBlox Android SDK:
Quickblox Android SDK framework documentation

Download Android SDK

Quickblox Android SDK, version 1.2.3

Framework changelog:

v1.2.3 — June 26, 2014

v1.2.2 — May 23, 2014

  • Content: translated File public url to new format

v1.2.1 — May 19, 2014

  • Fixed an issue with getting users with fullname with spaces
  • Fixed an issue with uploading content file with spaces in name
  • Fixed parser crash on HTC devices with Android 2.3
  • Set XMPP room name in QBChatService.getInstance().createRoom method

v1.2 — April 25, 2014

  • Chat
    • Renamed SessionListener to SessionCallback
    • Added ConnectionListener
  • General
    • Reduced amount of methods in jar file
    • bug fixes

v1.1 — January 14, 2014

  • Chat
    • Roster(contact list) API
    • Added methods to add/remove users to chat room

v1.0.2 — January 9, 2014

  • Errors handling fixes

v1.0.1 — December 30, 2013

  • Chat
    • Chat API wrapper
  • CustomObjects
    • Permissions API
    • Files API
    • Added ‘output’, ‘or’, ‘ctn’ operators
    • Multi creation of records
    • Multi update of records
    • Multi delete of records
  • Content
    • Ability to update blob’s file
  • General
    • Ability to set custom endpoints for API server, Chat server, TURN server, Content bucket name
    • Access to token expiration date
v0.8.2 — December 9, 2013
  • Improved the stability
v0.8.1 — April 29, 2013
  • Added method QBUsers.getUsersByPhoneNumbers - retrieve users by phone numbers
  • Improved the stability
v0.8 — March 14, 2013
  • Added method QBUsers.getUsersByLogins - retrieve users by logins
  • Added method QBUsers.getUsersByEmails - retrieve users by emails
  • Improved the stability
v0.7 — January 16, 2013
  • All APIs are covered
  • Renamed QBAuth.authorizeApp method to QBAuth.createSession


Feel free to comment on this page using the form below.

blog comments powered by Disqus