Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Vibrating device doesn't work

I actually have an app that I test with two devices. One LG GW620, and one Samsung Spica. I would like when User touch the screen, the device vibrate.

In fact, On the LG GW620, the device vibrate when I touch it. But on the spica doesn't...

I looked for settings on the spica, but Vibrator is check, so I don't understand why it doesn't vibrate.

In my app I have : <uses-permission android:name="android.permission.VIBRATE"></uses-permission>

and in the code :

Vibrator vibrator =(Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
            vibrator.vibrate(100);

But I think it is not the best thing to do that. I wish device vibrate for every click, but I don't know if I have to do a Vibrator for each OnClick ? Or if I could do only one Vibrator for all the application ?
And especially why it doesn't work on Spica ?

like image 571
Nanis Avatar asked Jun 24 '10 08:06

Nanis


People also ask

Why vibration is not working?

Check Accessibility Settings Apart from the sound settings, you'll also need to check the Accessibility menu on your Android to see if the vibration is disabled from there.

Why isn't my phone vibrating when I get a text Android?

There are two places where you need to turn on vibration: within the Messaging app, Menu > Settings > Notification settings (scroll down to find it); from the Home screen, Menu > Settings > Sound settings > Vibrate.

Why is my phone not buzzing?

Turn On Vibration In Accessibility Settings If Vibration is turned off in Accessibility settings, your iPhone won't vibrate even if the vibration motor is fully functional. Go to Settings -> Accessibility -> Touch and make sure the switch next to Vibration is turned on. You'll know the switch is on when it's green.


1 Answers

Funny. In your onClick for the button you should put the vibrate. And since it is in miliseconds I'd put something like 500 for half a second instead of .1 seconds.

void onCreate() {

    mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

    Button b = (Button) findViewById(R.id.button);
    b.setOnClickListener(new View.OnClickListener() {
        void onClick() {
            mVibrator.vibrate(500);
        }
    });
}
like image 160
Robby Pond Avatar answered Oct 16 '22 17:10

Robby Pond