Android Quickstart

Table of Contents

Usage

  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(
        context,
        new String[] {"scope:r", "scope:w"}
    );

    and then

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

    @Override
    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.

This website uses cookies - see our privacy policy for more information about cookies and your rights as a user. Click on "accept" to allow the cookie use.
More about this