Neither user 10036 nor current process has android.permission.DEVICE_POWER.

无人久伴 提交于 2020-01-15 03:42:08

问题


I need to power off device by button on my application. I add permission to manifest file:

 <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="13" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.DEVICE_POWER"/>

And use powerOff method on click button:

void powerOff(){
        PowerManager pm = (PowerManager) getSystemService(this.POWER_SERVICE);
        pm.goToSleep(SystemClock.uptimeMillis());
    }

When I click button I get error:

Neither user 10036 nor current process has android.permission.DEVICE_POWER.


回答1:


DEVICE_POWER is a restricted permission. PackageManager won't grant you this unless your app is signed with the system signature.



来源:https://stackoverflow.com/questions/15726352/neither-user-10036-nor-current-process-has-android-permission-device-power

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!