Skip to content

Instantly share code, notes, and snippets.

@azizkayumov
Created March 2, 2020 09:08
Show Gist options
  • Save azizkayumov/0acd4ab998f807d1497b79f19862fa7c to your computer and use it in GitHub Desktop.
Save azizkayumov/0acd4ab998f807d1497b79f19862fa7c to your computer and use it in GitHub Desktop.
/**
* Imports here
*/
class ShakeActivity : AppCompatActivity(), ShakeDetector.ShakeListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_shake)
Sensey.getInstance().init(this)
Sensey.getInstance().startShakeDetection(this)
}
override fun onShakeStopped() {
tvStatus.text = "Shake: Stopped"
}
override fun onShakeDetected() {
tvStatus.text = "Shake: Detected"
// this will show "Shake" even if this ShakeActivity destroyed
Toast.makeText(this, "Shake", Toast.LENGTH_SHORT).show()
}
override fun onDestroy() {
Sensey.getInstance().stop()
super.onDestroy()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment