Skip to content

Instantly share code, notes, and snippets.

@Venryx
Last active February 17, 2020 23:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Venryx/ca673aa3a3b559bbb0f939f43fdbd9bc to your computer and use it in GitHub Desktop.
Save Venryx/ca673aa3a3b559bbb0f939f43fdbd9bc to your computer and use it in GitHub Desktop.
Trigger SonicBomb shakes from your app
// Note: I'm not updating this anymore. For the latest version, see here: https://stackoverflow.com/a/60271550/2441655
val patterns = arrayOf(
"!WLALALALALALALALA;", // default
"!WTRG0TRG0TRG0TRG;", // pulse
"!WPJ0FPV7S1J600;" // sos
// you can add your own patterns by mixing and matching the vibration components
);
// strength is between 0 and 100; pattern follows the format seen above
fun SonicBomb_Shake(strength: Int, pattern: String) {
Log.i(TAG, "SonicBomb_Shake @strength($strength) @pattern($pattern)")
val intent = Intent()
intent.action = "com.sonicalert.v2.intent.test_shake"
intent.putExtra("current strength m", strength)
intent.putExtra("current pattern", pattern)
intent.putExtra("current alarm audio", false)
MainActivity.instance!!.sendBroadcast(intent)
}
fun SonicBomb_StopShake() {
val intent = Intent()
intent.action = "com.sonicalert.v2.intent.alarm_dismiss"
MainActivity.instance!!.sendBroadcast(intent)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment