Question

I have this line of code calling 2 seconds from the vibrator_service;

 Vibrator v = (Vibrator)
                        getSystemService(Context.VIBRATOR_SERVICE);
                        v.vibrate(2000);

and this in my manifest

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

But I am still getting a force close java.lang.security.exception: Requires Vibrate Permission. Have I declared the permission wrong??

Was it helpful?

Solution

You need to add a uses-permission tag in the manifest file (as a child of the manifest element, same as the permission tag):

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

As far as I know, the permission tag is only used to add additional text/graphic information to the permissions request when downloading the app, or to add new permissions to provide additional information to your users. I usually use both to be safe.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top