Android Quickstart

Table of Contents


  1. Add the manifestPlaceholders property with the clientId, clientSecret, environment, and redirectScheme keys to your build.gradle file.

    android {
        defaultConfig {
            manifestPlaceholders = [
                clientId      : "clientId",
                clientSecret  : "secret",
                environment   : "production",
                redirectScheme: "com.example",
                debug         : "false"
The debug flag is overwritten if your app is not debuggable.
  1. To log in, use the startActivityForResult method with login intent.

    Intent loginIntent = Data4LifeClient.getLoginIntent(context, null);

    or with custom scopes

    Intent loginIntent = Data4LifeClient.getLoginIntent(
        new String[] {"scope:r", "scope:w"}

    and then

    startActivityForResult(loginIntent, Data4LifeClient.D4L_AUTH);
  2. Handle the login result in your onActivityResult method.

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == D4L_AUTH){
            if (resultCode == RESULT_OK){
                // you are now logged in
  3. Get the data4life client instance inside Activity or Fragment.

    client = Data4LifeClient.getInstance();
  4. Now you can use available [public methods](#queries-and-actions) which return results on background thread.

With your consent, we will analyze your behaviour on the website to improve the website for all users. If you consent to the transmission of analysis data, click “Accept”. You can use the website without giving consent to analyze your behaviour. For further information, visit the privacy policy.