i wont to make the device vibrate when press down and stop if i move my
finger
how can i make the device vibrate if i press down and stop vibrate if i
move my finger of ?? now this work with the sound but it not working with
the vibrate and this is the code `
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
// TODO Auto-generated method stub
if(MotionEvent.ACTION_DOWN == arg1.getAction())
{
mp.start();
df= (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
}
else
if(MotionEvent.ACTION_UP == arg1.getAction())
{
mp.stop();
try {
mp.prepare();
try {
df.wait(arg1.getDownTime());
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//df.cancel();
}
return false;
}
});
}
`
No comments:
Post a Comment