振动器许可强制关闭 [英] Vibrator permission force close

查看:368
本文介绍了振动器许可强制关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这行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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆