ForgeRock Developer Experience

Step 3. Initialize the SDK

In this step, you enable debug logging during development.

You then add a call to the FRAuth.start() method, which initializes the SDK and loads the configuration you have defined in the previous step.

Enable debug logging and initialize the SDK

  1. Open the project’s MainActivity class file.

    For example, app  java  com.example.quickstart  MainActivity.

  2. Enable debug logging and initialize the SDK in the onCreate() method after the generated code:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
     // Add these lines:
        Logger.set(Logger.Level.DEBUG);
        FRAuth.start(this);
    }
  3. Add the required import statements for org.forgerock.android.auth.FRAuth and org.forgerock.android.auth.Logger.

    import org.forgerock.android.auth.FRAuth;
    import org.forgerock.android.auth.Logger;

Check point

You have now added debug logging to your app and initialized the SDK.

  1. To test the setup so far, in Android Studio, select Run  Run 'app'.

    If everything is configured correctly, the app builds, and the default emulator will run the application.

  2. Open the Logcat pane. The SDK will generate output similar to the following if everything is configured correctly:

-- PROCESS STARTED (14305) for package com.example.quickstart --
11:03:33  D  Using SharedPreference: SecuredSharedPreferences

If you get errors when running the app, check the app  res  values  strings.xml has the correct values. Refer to Step 2. Configure connection strings.

In the next step, you create the initial user interface to display the current authentication status, and add buttons to log in and log out.

Copyright © 2010-2024 ForgeRock, all rights reserved.