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
-
Download the Hawcx AAR file
-
In your Android project, create a new folder named
libs
in theapp
directory if it doesn't already exist. -
Copy the downloaded AAR file into the
libs
folder. -
Please make sure that names match with the names provided in the document.
Step 2: Update Gradle Configuration
-
Open your app-level
build.gradle
file. -
Add the following to the
dependencies
section:
- Sync your project with the Gradle files.
Step 3: Initialize Hawcx
-
Open your main Application class. If you don't have one, create a new class that extends
Application
. -
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"); }
}
- 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
}