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();
}