2

I read a lot about this problem on Stackoverflow but not of the Helps her works at my problem.

In my Source Code I have this.

vibretor  = (Vibrator) this.getSystemService(VIBRATOR_SERVICE);
vibretor.vibrate(600);

and in the AndroidManifeste.xml I have the Permission

<uses-permission android:name="android.permission.VIBRATE"/>

this is all right I think because i looked it up at http://developer.android.com

but it does not worke at all :( So have someone of you a idea how I can get it working?

My testing Devices are: Eee Pad Transformer, Samsung Galaxy S2 and Samsung Galaxy Tab 10.1

Phil
  • 2,326
  • 2
  • 17
  • 15

2 Answers2

5

Problem solved.

The problem was that, under android 4.0, the vibration settings must be

Vibration on touch

and not

Ringtone or Notification

and then it work with my code.

vibretor  = (Vibrator) this.getSystemService(VIBRATOR_SERVICE);
vibretor.vibrate(600);
Pang
  • 9,073
  • 146
  • 84
  • 117
Phil
  • 2,326
  • 2
  • 17
  • 15
1
public void vibrate(int duration)
              {
   Vibrator v = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
   v.vibrate(duration);    
              }
vibrate(10000);
Iman Marashi
  • 5,207
  • 34
  • 50
Ponmalar
  • 6,814
  • 10
  • 48
  • 77
  • 1
    Why you want to get the parameter as `String` and then convert it to `int`? Why don't you get it as a `int` on first hand? – COD3BOY May 04 '12 at 06:36
  • I have used this in my Application. In that i have get the vibration duration from textbox, so that i have passed as string. Now check the edited code. – Ponmalar May 04 '12 at 06:43