Vibration alert not working

by Farhan » Wed, 05 Aug 2009 09:40:06 GMT

Sponsored Links

I am trying to use vibration alert with notification and flash lights
within a service. I wrote the following code:

        private void vibrationAlert() {
                int icon = R.drawable.icon;
                CharSequence tickerText = "Some text";
                long when = System.currentTimeMillis() + 2000;

                Notification notification = new Notification(icon, tickerText,
                Context context = getApplicationContext();
                CharSequence contentTitle = "Some text";
                //CharSequence contentText = "Some text";
                Intent notificationIntent = new Intent(this,
                PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
notificationIntent, 0);

                notification.setLatestEventInfo(context, contentTitle, 
                notification.defaults |= Notification.DEFAULT_VIBRATE;
                long[] vibrate = {0,100,200,300};
                notification.vibrate = vibrate;
                notification.defaults |= Notification.DEFAULT_LIGHTS;
                notification.ledARGB = 0xff00ff00;
                notification.ledOnMS = 300;
                notification.ledOffMS = 1000;
                notification.flags |= Notification.FLAG_SHOW_LIGHTS;
                NotificationManager nm = (NotificationManager) getSystemService
                nm.notify(MY_ID, notification);

But when I run my application, I get the following error:

08-04 20:27:20.228: ERROR/AndroidRuntime(891): Uncaught handler:
thread main exiting due to uncaught exception
08-04 20:27:20.317: ERROR/AndroidRuntime(891):
java.lang.SecurityException: Requires VIBRATE permission
08-04 20:27:20.317: ERROR/AndroidRuntime(891):     at
08-04 20:27:20.317: ERROR/AndroidRuntime(891):     at
08-04 20:27:20.317: ERROR/AndroidRuntime(891):     at$Stub$Proxy.enqueueNotification
08-04 20:27:20.317: ERROR/AndroidRuntime(891):     at
08-04 20:27:20.317: ERROR/AndroidRuntime(891):     at

In the manifest file I have added the following lines in manifest,
application, activity and the service element:


But I am still getting the error. It is obvious that I am making some
mistake defining the permissions. Can anyone tell me what I am doing
wrong? I am using Android 1.5_r3.



Vibration alert not working

by nEx.Software » Wed, 05 Aug 2009 22:23:16 GMT

 ou don't need any permissions to use the LED notification,
but for the Vibrate, you will need to use:

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

On Aug 4, 6:39pm, Farhan <> wrote:

Sponsored Links

Vibration alert not working

by Farhan » Wed, 12 Aug 2009 05:03:31 GMT

 hanks a lot! It is working now.

On Aug 5, 9:23am, "nEx.Software" <>

Other Threads

1. Necus ternyata jagoan donlot

ginger bread bakal kaya apa ya fiturnya.
froyo aja dah mantap banget.

2010/5/21 lucky sebastian <>


2. Android on iPhone

A recent post on engadget (
apple-outs-iphone-firmware-2-2-beta-1/) stated that the new firmware
2.2 (which is now open for developers) can emulate Android on the
iPhone. Inintially i was thinking to buy an iPhone but while Android /
G1 cuming up, i thought buying G1 wud be a better option. I am in
India, an none of the devices wud be affordable, can u please suggest
me wat shud i buy, as some relatives are cumin from US next month.

3. Samsung SC, di Jaksel

4. Memory leaks???

5. Restricting Softkeyboard Kyes for EditText

6. how browser decides html size on 2.1

7. Apa yg keren di depan