推 gpc:不能發intent 要用wakelock 04/15 16:23
→ cooper6334:所以是用PowerManager囉? 04/15 16:31
→ Gway:你的觀螢幕式就切電源而已嗎? 還是有進入suspend to memory? 04/15 16:38
→ cooper6334:就是按一下power鍵讓螢幕變黑 04/15 16:42
→ cooper6334:我現在用PowerManager.WakeLock.acquire() 04/15 16:44
→ cooper6334:uses-permission 也有設了,可是還是沒有反應 04/15 16:44
→ cooper6334:我發覺lock以後我鬧鐘就不會等一等變暗了 04/15 16:48
→ cooper6334:但是我希望的是app能主動打開螢幕 04/15 16:49
→ cooper6334:喔而且內建的鬧鐘好像是綁在螢幕鎖上的,一整個很神奇 04/15 20:42
推 lausai:你有加上ACQUIRE_CAUSES_WAKEUP flag嗎 @@? 04/15 22:01
→ lausai:官網上寫要加這個flag才會強迫screen亮起來 04/15 22:01
感謝樓上,就是這樣
private PowerManager mPowerManager;
PowerManager pm = (PowerManager) getSystemService(this.POWER_SERVICE);
mWakeLock1 = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK |
PowerManager.ACQUIRE_CAUSES_WAKEUP,
this.getClass().getCanonicalName());
mWakeLock1.acquire();
這樣執行到這邊的話,手機就會自動打開了
不過會卡在螢幕鎖那邊進不來
手機內建的鬧鐘是綁在螢幕鎖上的,應該不是app層能做的吧,也不是我想做的
※ 編輯: cooper6334 來自: 118.161.52.169 (04/15 22:47)