3

WAKE_LOCK在 AndEngine中给予许可是强制性的吗?如果我尝试删除此WAKE_LOCK权限,则会收到 SecurityException。

日志错误:

01-28 09:57:48.417: DEBUG/dalvikvm(166): Added shared lib /system/lib/libjni_latinime.so 0x437577d0
01-28 09:59:02.966: ERROR/AndEngine(225): You have to add
01-28 09:59:02.966: ERROR/AndEngine(225):     <uses-permission android:name="android.permission.WAKE_LOCK"/>
01-28 09:59:02.966: ERROR/AndEngine(225): to your AndroidManifest.xml !
01-28 09:59:02.966: ERROR/AndEngine(225): java.lang.SecurityException: Neither user 10024 nor current process has android.permission.WAKE_LOCK.
01-28 09:59:02.966: ERROR/AndEngine(225):     at android.os.Parcel.readException(Parcel.java:1218)
01-28 09:59:02.966: ERROR/AndEngine(225):     at android.os.Parcel.readException(Parcel.java:1206)
01-28 09:59:02.966: ERROR/AndEngine(225):     at android.os.IPowerManager$Stub$Proxy.acquireWakeLock(IPowerManager.java:178)
01-28 09:59:02.966: ERROR/AndEngine(225):     at android.os.PowerManager$WakeLock.acquire(PowerManager.java:228)
01-28 09:59:02.966: ERROR/AndEngine(225):     at org.anddev.andengine.ui.activity.BaseGameActivity.acquireWakeLock(BaseGameActivity.java:200)
01-28 09:59:02.966: ERROR/AndEngine(225):     at org.anddev.andengine.ui.activity.BaseGameActivity.doResume(BaseGameActivity.java:166)
01-28 09:59:02.966: ERROR/AndEngine(225):     at org.anddev.andengine.ui.activity.BaseGameActivity.onWindowFocusChanged(BaseGameActivity.java:83)
01-28 09:59:02.966: ERROR/AndEngine(225):     at com.android.internal.policy.impl.PhoneWindow$DecorView.onWindowFocusChanged(PhoneWindow.java:2027)
01-28 09:59:02.966: ERROR/AndEngine(225):     at android.view.View.dispatchWindowFocusChanged(View.java:3694)
01-28 09:59:02.966: ERROR/AndEngine(225):     at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:655)
01-28 09:59:02.966: ERROR/AndEngine(225):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1782)
01-28 09:59:02.966: ERROR/AndEngine(225):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-28 09:59:02.966: ERROR/AndEngine(225):     at android.os.Looper.loop(Looper.java:123)
01-28 09:59:02.966: ERROR/AndEngine(225):     at android.app.ActivityThread.main(ActivityThread.java:4203)
01-28 09:59:02.966: ERROR/AndEngine(225):     at java.lang.reflect.Method.invokeNative(Native Method)
01-28 09:59:02.966: ERROR/AndEngine(225):     at java.lang.reflect.Method.invoke(Method.java:521)
01-28 09:59:02.966: ERROR/AndEngine(225):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
01-28 09:59:02.966: ERROR/AndEngine(225):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
01-28 09:59:02.966: ERROR/AndEngine(225):     at dalvik.system.NativeStart.main(Native Method)
4

2 回答 2

3

不需要,请参阅:https ://github.com/nicolasgramlich/AndEngine/blob/GLES2-AnchorCenter/src/org/andengine/engine/options/WakeLockOptions.java#L24 。使用SCREEN_ON.

于 2013-01-29T20:39:07.577 回答
0

无需设置wakelock权限,但必须设置,因为如果屏幕计时器到期(例如15或20秒),屏幕将空白,中断游戏,您必须再次打开(唤醒)手机。所以,是必须的。

于 2015-02-11T17:48:02.200 回答