Skip to content

Creating a New Project with Hawcx

This guide will walk you through the process of creating a new Android project with Hawcx integration from scratch.

Prerequisites

  • Android Studio installed on your development machine
  • Basic knowledge of Android development

Steps

  1. Create a New Android Project
  2. Open Android Studio
  3. Click on "File" > "New" > "New Project"
  4. Choose "Empty Activity" and click "Next"
  5. Set your application name, package name, and minimum SDK (26 or higher)
  6. Click "Finish" to create the project

  7. Add Hawcx AAR

  8. Download the Hawcx AAR file.
  9. Create a new folder named libs in your project's app directory
  10. Copy the downloaded AAR file into the libs folder
  11. Please make sure that names match with the names provided in the document.

  12. Update Gradle Configuration

  13. Open your app-level build.gradle file
  14. Add the following to the dependencies section:

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

  15. Initialize Hawcx Authentication

  16. Create a new Application class:

       import android.app.Application;
       import com.hawcx.HawcxInitializer;
    
       public class MyApplication extends Application {
           @Override
           public void onCreate() {
               super.onCreate();
               HawcxInitializer.getInstance().init(this, "YOUR_API_KEY_HERE");
           }
       }
    
    - Register the Application class in your AndroidManifest.xml:

    <application
        android:name=".MyApplication"
        ...>
        <!-- Your activities and other components -->
    </application>
    
  17. Implement Hawcx Features

  18. Now you can start using Hawcx features in your activities and fragments.
  import com.hawcx.auth.SignIn;
  import com.hawcx.HawcxInitializer;

  public class MainActivity extends AppCompatActivity implements SignIn.SignInCallback {
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);

          // Example: Implement secure login
          // User Login
          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
          }

          // If lastuser found
          @Override
          public void initiateBiometricLogin(Runnable onSuccess) {
              // Handle Biometric Auth 
          }

          // If no last user is found 
          @Override
              public void showEmailSignInScreen() {
                  // Handle the Email screen
              }
      }
  }