Quick Start Guide for Android

This guide will help you get up and running with Backendless quickly so you can develop Android applications. At the end of the guide you will have a configured working environment and a basic project with the code communicating with the Backendless services.

  1. Login to your Backendless account or register to create a new one.
  2. Download Android SDK package from the Backendless SDK Downloads page and unzip it to a temporary folder.

  3. Create a new Android application project or open an existing project.
  4. Add backendless.jar from the SDK distribution to your project classpath. Alternatively, you can add the backendless dependency by looking it up in maven – simply search for backendless and pick the 3.0.25 version.

    Adding a library for your module:

    Looking up the Backendless library:

  5. Open “AndroidManifest.xml” from the root of your project and add the following sections:
    • Add the android.permission.INTERNET  and android.permission.ACCESS_NETWORK_STATE  permissions to the application’s manifest file. To do so, add the following lines into the <manifest>  element:

      The image below demonstrates where in the file to add the permissions:

  6. Open the main activity class and add the following import statements:

  7. Get your Backendless application keys for Android SDK from the Backendless Console. The keys can be found at the Manage > App Settings section:
  8. Add Backendless application initialization code block to your main Activity “onCreate” method to set the application ID and secret key:

  9. Add some code which uses the Backendless API to test your application. For example, the code below registers a new Backendless user (instead of used in the code, consider using an email address  where you can check email – your Backendless backend will send out an email welcoming the user to your app):

  10. Run your application. A new Backendless user will be registered with Backendless. You can verify the registered user in the Data section of the Backendless Console:
  11. Next example will use the Backendless API to save a plain Java object from the Android client. First declare a class which will be saved in Backendless. Make sure the class is declared in its own .java file and is not an inner class. It is also important that the class has the default no-argument constructor:

  12. Use the code snippet below to store an instance of the “Comment” class from the registered user:

  13. Now you can verify in the Backendless Console that the “Comment” data table has been created with the columns corresponding to the properties of the Comment class and it contains the saved object.