I want the device to start vibrating for some amount of time when screen timeout option enables(when the light dims, before the screen shuts off).I know how to set up both functions individually, but I can't seem to manage to get them in the right order for this to work, so I need your help. Thanks and cheers!
Asked
Active
Viewed 68 times
-1
-
Use this tutorial http://stackoverflow.com/a/17066803/2563355 – Петър Петров Feb 23 '15 at 13:16
1 Answers
0
Use the vibrator class to initiate vibration
new Handler().postDelayed(new Runnable()
{
@Override
public void run()
{
Vibrator vib = (Vibrator) getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE);
// Vibrate for 500 milliseconds
vib.vibrate(5);
}
}, 30000); //30 sec
Edit:
Don't forget as I did to declare in the app manifest file
<uses-permission android:name="android.permission.VIBRATE"/>

J.Vassallo
- 2,282
- 3
- 15
- 14
-
I've done that, but i need it to trigger when screen timeout starts (e.g. after 30 seconds). – Marko Balic Feb 23 '15 at 13:24