Android:如何使用PowerManager.wakeUp?

Ala*_*ate 1 android wakeup powermanager

我想使用PowerManager 的方法wakeUp。Eclipse(ADT)不协调此方法。但是,相反的“ goToSleep”没有问题:

PowerManager pm = (PowerManager) MyApplication.getAppContext().getSystemService(Context.POWER_SERVICE);
pm.wakeUp(SystemClock.uptimeMillis()); //Detected as error by eclipse
pm.goToSleep(SystemClock.uptimeMillis()); //Not detected as error and work well
Run Code Online (Sandbox Code Playgroud)

Eclipse错误:

The method wakeUp(long) is undefined for the type PowerManager
Run Code Online (Sandbox Code Playgroud)

Eclipse向我提出了一个快速修复程序,但是我有同样的错误:

((Object) pm).wakeUp(SystemClock.uptimeMillis()); //the same error 
Run Code Online (Sandbox Code Playgroud)

这是一个错误还是仅我一个?谢谢 !

Com*_*are 5

首先,正如Luksprog指出的那样,该方法是API级别17的新增功能。

此外,它还需要获得DEVICE_POWER许可,该许可只能由使用与用于固件签名相同的签名密钥签名的应用程序持有。