Invoking the bug reporter

Automatic Invocations

There are 2 different ways to invoke the bug reporter, enumerated by Buglife.InvocationMethod:

  1. SHAKE: Invokes when the user shakes their device.

    Buglife.setInvocationMethod(InvocationMethod.SHAKE);
    
  2. SCREENSHOT: Invokes when the user manually takes a screenshot with their device.

    Buglife.setInvocationMethod(InvocationMethod.SCREENSHOT);
    
  3. NONE: Disables all except manual invocations.

    Buglife.setInvocationMethod(InvocationMethod.NONE);
    

    This may be preferable for production builds. In this case, we recommend embedding a hidden button somewhere in your app which manually presents the bug reporter, so that you can still collect logs & other information.

For both automatic invocations (SHAKE and SCREENSHOT), a screenshot of the current activity is captured & attached to the bug report draft.

We recommend using the screenshot invocation for most apps. Taking screenshots to report feedback comes naturally to most users, and screenshots are still saved to the user's device as expected.

Manual & Custom Invocations

You can manually present the bug reporter activity using:

Buglife.showReporter();

Unlike the SHAKE & SCREENSHOT invocations, manually presenting the bug reporter activity does not automatically capture & attach a screenshot to the bug report draft.

This is useful for situations where attaching a screenshot of the immediate application state doesn't make sense (for example, if you have a "Report Bug" option in your app's settings screen).

Manually capture & attach screenshots

You can capture a screenshot of your app at any moment using Buglife.getScreenshotBitmap(). You can then create an Attachment object from the generated bitmap, and add this to your bug report draft using the Buglife.addAttachment() method. For example

// Capture a screenshot of the current activity
Bitmap screenshot = Buglife.getScreenshotBitmap();
// Create an Attachment object with the generated screenshot
Attachment attachment = new Attachment
		.Builder("Screenshot.png", Attachment.TYPE_PNG)
		.build(screenshot);
// Queue the Attachment for the next bug report draft
Buglife.addAttachment(attachment);
// Show the bug reporter activity. This will include the queued attachment
Buglife.showReporter();