I am trying to hit an API when user shake a device 10 times. I have tried many git sample and stack overflow solution but non of them did solve my problem. Some of them detecting shake before 10 times or after 10 times. I have tried Seiamic and ShakeDetector libraries. Please give me some valuable solution.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
have a static variable that gets incremented every time a shake is detected.
By Using SensorListener
Please check this ticked answer...
You have to adjust SHAKE_THRESHOLD value to achieve this
How to detect shake event with android?
Thank you!
I have done that using this library :
1) Add the dependecy in your build.gridle file
2) Give the permission to your app manifest file
if you will run in background, register your broadcast receiver
3) start that in onCreate method Like this :
4) override onStop method and stop that
5) override onDistroy method and distroy like this :
(*) Optional step : if you will run in background, create your broadcast receiver