Vibration alert not working

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


Sponsored Links
 Hello,

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,
when);
                Context context = getApplicationContext();
                CharSequence contentTitle = "Some text";
                //CharSequence contentText = "Some text";
                Intent notificationIntent = new Intent(this,
NotificationActivity.class);
                PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
notificationIntent, 0);

                notification.setLatestEventInfo(context, contentTitle, 
tickerText,
contentIntent);
                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
(Context.NOTIFICATION_SERVICE);
                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
android.os.Parcel.readException(Parcel.java:1234)
08-04 20:27:20.317: ERROR/AndroidRuntime(891):     at
android.os.Parcel.readException(Parcel.java:1222)
08-04 20:27:20.317: ERROR/AndroidRuntime(891):     at
android.app.INotificationManager$Stub$Proxy.enqueueNotification
(INotificationManager.java:152)
08-04 20:27:20.317: ERROR/AndroidRuntime(891):     at
android.app.NotificationManager.notify(NotificationManager.java:94)
08-04 20:27:20.317: ERROR/AndroidRuntime(891):     at
com.russoue.android.service.MyService.vibrationAlert(MyService.java:
239)

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

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

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.

Thanks.

--~--~---------~--~----~------------~-------~--~----~



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 <russ...@gmail.com> 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" <email.nex.softw...@gmail.com>
wrote:
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Parcelable iterface implementation in parent class

Hi at all,

I have this doubt thinking about the Parcelable interface, question
is:

Let A and B two type of object, with B that extend A, when I implement
the parcelable interface for A all is ok but when I have to implement
the parcelable interface for B can I write in parcel only B object
fields ? can I be sure that the system call the parcelable interface
implementation from object A?

Thanks so much and excuse-me for by english

-- 

2. Access to Google Reader API

Hello,

I am trying to develop a Google Reader app for Android. This app was
working fine before today with the following code :

monTransport = GoogleTransport.create();
GoogleHeaders entete = (GoogleHeaders) monTransport.defaultHeaders;
entete.setApplicationName("ActuXml");
entete.gdataVersion = "2";
entete.setGoogleLogin(jeton);
XmlHttpParser parseur = new XmlHttpParser();
parseur.contentType = "text/xml; charset=UTF-8";
parseur.namespaceDictionary = NAMESPACE_DICTIONARY;
monTransport.addParser(parseur);
HttpRequest requete = monTransport.buildGetRequest();
requete.url = new GenericUrl("http://www.google.com/reader/atom/" +
finurl);
try {
   flux = requete.execute().parseAs(ReaderItems.class);
} catch (IOException e) {
 // TODO Auto-generated catch block
 e.printStackTrace();
}

I get a valid token by using the android API 2.0 code :

AccountManager manageurcomptes = AccountManager.get(getBaseContext());
Bundle bundle = manageurcomptes.getAuthTokenByFeatures("com.google",
AUTH_TOKEN_TYPE,  null, moi,                       null, null, null,
null).getResult();
   if (bundle.containsKey(AccountManager.KEY_AUTHTOKEN)) {
    authJeton = bundle.getString(AccountManager.KEY_AUTHTOKEN);
    util = bundle.getString(AccountManager.KEY_ACCOUNT_NAME);

This code was working at the beginning of this week, today it doesn't
work anymore. Any change on the server side for the unofficial Google
Reader API ?

-- 

3. Passing object via intent

4. Can two application's content providers share one authority?

5. Adding separators to a ListView

6. Using <Uses-Library> in android application

7. Android Contact Search