Skip to content

Integrating Hawcx into an Existing Project

This guide will walk you through the process of adding Hawcx to your existing Android project. By following these steps, you'll be able to enhance your app's security features quickly and efficiently.

Prerequisites

  • Android Studio installed on your development machine
  • An existing Android project
  • Minimum SDK version 26 or higher

Step 1: Add the Hawcx AAR

  1. Download the Hawcx AAR file

  2. In your Android project, create a new folder named libs in the app directory if it doesn't already exist.

  3. Copy the downloaded AAR file into the libs folder.

  4. Please make sure that names match with the names provided in the document.

Step 2: Update Gradle Configuration

  1. Open your app-level build.gradle file.

  2. Add the following to the dependencies section:

dependencies {
    implementation files('libs/hawcx.aar')
    // Other dependencies...
}
  1. Sync your project with the Gradle files.

Step 3: Initialize Hawcx

  1. Open your main Application class. If you don't have one, create a new class that extends Application.

  2. Add the following code to initialize Hawcx:

import com.hawcx.HawcxInitializer;

public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        HawcxInitializer.getInstance().init(this, "YOUR_API_KEY_HERE");    }
}
  1. If you created a new Application class, make sure to register it in your AndroidManifest.xml:
<application
    android:name=".MyApplication"
    ...>
    <!-- Your existing application components -->
</application>

Step 4: Implement Hawcx Features

Now that Hawcx is integrated into your project, you can start using its features. Here are a few examples:

Secure User Authentication

import com.hawcx.auth.SignIn;

// In your login activity or fragment
SignIn loginAct = HawcxInitializer.getInstance().getSignIn();
// Check last logged in user and signal biometric auth if applicable
loginAct.checkLastUser(this);

loginAct.signIn(email, this);

@Override
public void onSuccessfulLogin(String loggedInEmail) {
    // Handle successful login
}

@Override
public void showError(String errorMessage) {
    // Handle login failure
}