Integrate Redpen Android SDK into your Application

Pre-Requisites:

  1. Create a Redpen Widget for Mobile. Follow the steps of this,document if you have not created one already.
  2. To configure Redpen Android SDK, you will need the widget ID of the mobile widget. Refer to this, document to get the Reden widget ID.

To integrate the Redpen Android SDK into your application, configure your android application as below:

Add Dependency

Note: Make sure you have added or used mavencentral in the repositories.

1. Modify your build.gradle. Add the package to the dependencies. The latest version of our SDK can be found on the maven central page of our SDK.

Copied to clipboard

  //build.gradle

  dependencies { 
      ...
      implementation 'ai.redpen:redpen-ai-capture-widget-android:<THE_LATEST_VERSION_OF_REDPEN_SDK>'
      ...
  }
 

2. Make sure the data binding is enabled.

Copied to clipboard

  //build.gradle

  android {
      ...
      dataBinding {
          enabled = true
      }
      ...
  }
 

Initialize the Redpen Capture SDK

Add the following code snippet to the onCreate method of your Application class.

Copied to clipboard

import ai.redpen.capture.sdk.RedpenWidget;
import ai.redpen.capture.sdk.utils.RedpenInvocationEvent;

public class <Your Application Class> extends Application {
    @Override
    public void onCreate() {
    ...  // Initialize Redpen Widget
    RedpenWidget.getInstance()
        .initialize(this, "WIDGET_ID")
        .setRedpenInvocationEvents(RedpenInvocationEvent.DEVICE_SHAKE) // This is optional. Add this line only if you want to let users capture screenshot by shaking their device.
        .build();
    }
}
 

Capture screenshots using custom events

If you want to capture screenshots with custom events (e.g. button click), call the RedpenWidget.captureNow() method as shown in the below example:

Copied to clipboard

// Your activity class
import ai.redpen.capture.sdk.RedpenWidget;

public void onFeedbackClick(View view) {
    RedpenWidget.captureNow(); 
}
 
--> -->