问题
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??
回答1:
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.
来源:https://stackoverflow.com/questions/12523265/vibrator-permission-force-close