ForgeRock SDKs

Initialize the Android SDK

To get started, update your application to:

  • Enable debug logging during development.

  • Call the FRAuth.start() method, which initializes the SDK, loading the configuration you have defined.

Follow these steps:

  1. Open the project’s MainActivity class file.

    For example, app/src/main/java/com/example/forgerocksdktutorial/MainActivity.java.

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

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Add these lines:
    Logger.set(Logger.Level.DEBUG);
    FRAuth.start(this);

    Import org.forgerock.android.auth.FRAuth and org.forgerock.android.auth.Logger as necessary.

  3. Open the project’s manifest file.

    For example, app/src/main/AndroidManifest.xml.

    • If the AM server in your deployment does not use the HTTPS protocol, add an android:usesCleartextTraffic="true" attribute to the <application> element.

    • If your application uses any of the Android location services; for example, the SDK’s location matching or geofencing features, add one of the following properties to the AndroidManifest.xml file:

      <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION/>
      <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION/>

      For information about which permission to use, see Location permissions in the Google Developer Documentation.

    An AndroidManifest.xml file with support for cleartext traffic resembles the following:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.forgerocksdktutorial">
    
        <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:roundIcon="@mipmap/ic_launcher_round"
            android:supportsRtl="true"
            android:theme="@style/Theme.ForgeRockSDKTutorial"
            android:usesCleartextTraffic="true">
            <activity
                android:name=".MainActivity"
                android:exported="true">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
        </application>
    
    </manifest>
Copyright © 2010-2022 ForgeRock, all rights reserved.