Using a wakelock in a service Android 1.5

前端 未结 2 1540
情深已故
情深已故 2021-02-09 22:35

Hello I am trying to use a service to control a wakelock so I can permanently leave the screen on when my application is running. I create the wakelock and activate it in onCrea

2条回答
  •  孤城傲影
    2021-02-09 23:23

    Aren't you missing the line

        PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "My Tag");
    

    in onDestroy()? It is a local variable in onCreate(), but it is not declared in onDestroy() at all.

    Or, more probable, you may want to make it a field of class WakeLockService instead of a local variable.

提交回复
热议问题