振动器许可强制关闭 [英] Vibrator permission force close
问题描述
我有这行code调用2秒从的 vibrator_service
;
I have this line of code calling 2 seconds from the vibrator_service
;
Vibrator v = (Vibrator)
getSystemService(Context.VIBRATOR_SERVICE);
v.vibrate(2000);
和这在我的清单
<permission
android:name="android.permission.VIBRATE" ></permission>
但我仍然得到一个强制关闭 java.lang.security.exception:需要振动权限
。难道我宣布允许错??
But I am still getting a force close java.lang.security.exception: Requires Vibrate Permission
. Have I declared the permission wrong??
推荐答案
您需要添加在manifest文件中的使用许可权
标记(作为一个孩子的清单
元素,同为许可
标记):
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.
这篇关于振动器许可强制关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!