Invoke

This page describes in detail all the different methods that can be used to invoke the SDK.

Invoke manually

By default, the SDK is invoked when a user shakes their device. You don't need to code anything.

But if you want to, you can customize that.

Let's look at an example. You want your users to invoke SDK either when they shake their device, or when they take a screenshot. To do that, call Shake.getReportConfiguration() before Shake.start() and pass one or more desired values.

App.kt
Shake.getReportConfiguration().isInvokeShakeOnShakeDeviceEvent = true
Shake.getReportConfiguration().isInvokeShakeOnScreenshot = true
Shake.start(this)

This method also enables you to change the preferred invocation event on-the-go during runtime. Here’s a list of all available ones below, feel free to use any combination of these.

App.kt
Shake.getReportConfiguration().isInvokeShakeOnShakeDeviceEvent = true
Shake.getReportConfiguration().isShowFloatingReportButton = true
Shake.getReportConfiguration().isInvokeShakeOnScreenshot = true
Shake.getReportConfiguration().isInvokeShakeOnRightEdgePan = true

Shaking

The default, shaking gesture causes the SDK to pop up.

note

In case you want to test Shake SDK in Android Emulator, it’s useful to know that emulator’s default shaking gesture is too weak to invoke Shake.

Button

This invocation event will create the floating button on top of your app's UI which users can clearly see at all times.This button can be dragged to a more suitable position.

note

In the emulator, you might need to click the button twice if one click doesn’t do it. Also, system interface elements may sometimes get in a way of the button.

Taking a screenshot

The SDK will be invoked when users make a screenshot while using your app.

note

The only way for any SDK to realize that a screenshot has been captured is to monitor the screenshots directory. Because of that, if you opt for this invocation method, the storage permission will be requested from a user when they launch your app.

Right Edge Pan

Invoke Shake with a one-finger swiping gesture from the right edge of the screen.

note

The right edge pan gesture won’t work if performed over a ListView or ScrollView. You can use one of the alternative ways to invoke Shake instead.

Invoke through code

You can invoke SDK through code by calling the Shake.show() method anywhere after Shake.start(), optionally attaching files and/or Metadata. Here’s an example:

App.kt
fun example() {
Shake.setMetadata("key", "value")
Shake.show(createShakeReportData())
}
private fun createShakeReportData(): ShakeReportData {
return object : ShakeReportData {
// From SDK Version 12.0 Quick facts are deprecated,
// so they're set to return null in this code example.
override fun quickFacts(): String {
return null
}
override fun attachedFiles(): List<ShakeFile> {
return ArrayList()
}
}
}

All other data, like Activity history or Black box, is automatically included in every user’s bug report — no additional code required.