Skip to content

Setting up Parse SDK with Android

Parse SDK init in Android

Parse SDK Open SourceSo now that Parse.com is gone, there’s still the option of using your own server w/ their open-source server code.

 

You can find info on setting that up on their site linked above. But this post is about setting up your Android Studio project w/ the Parse SDK.

 

  1. If you don’t have it, get Android Studio: https://developer.android.com/studio/index.html
  2. Add Parse: https://github.com/ParsePlatform/Parse-SDK-Android
    1. Downloaded SDK
    2. Put jar file in ‘libs’ dir same level as project ‘java’ dir under src/main
    3. Added Gradle line for jar file to build.gradle (for app module, not project):
      1. compile ‘com.parse:parse-android:1.13.1’Parse SDK in Android
  3. Restarted project (it wasn’t picking up the SDK)
  4. Added imports, init call and login call to test

Parse SDK init in Android

As you can see, I created a class to house some static methods including initializing the Parse server connection. The ‘initialized’ flag is to prevent it from happening multiple times in a given execution of the app.

 

Parse.initialize(new Parse.Configuration.Builder(getApplicationContext())
    .applicationId(“<app id>“)
    .clientKey("-----n/a-----")
    .server(“<api url>”)
    .build()
);

I was connecting to an existing database/Parse server so I tested it w/ a quick login…

ParseUser user = ParseUser.logIn(“<username>”, “<password>”); // returns user