Created
March 2, 2020 09:08
-
-
Save azizkayumov/0acd4ab998f807d1497b79f19862fa7c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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