2012-10-02 62 views
1

這是問題所在。我使用Ice Cream Sandwich工作在Android設備上,當我通過Wifi從計算機ping通設備時,我想喚醒設備。睡覺安卓設備在ping時喚醒

我在「嘗試」使用下面的一段代碼來喚醒設備,但它似乎不工作。

WakeLock lock = ((PowerManager) getSystemService(POWER_SERVICE)).newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK 
      | PowerManager.ACQUIRE_CAUSES_WAKEUP, "TAG"); 
lock.acquire(); 

KeyguardManager km = (KeyguardManager) getSystemService(KEYGUARD_SERVICE); 
    requestWindowFeature(Window.FEATURE_NO_TITLE); 

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN | 
      WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | 
      WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | 
      WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON, 
      WindowManager.LayoutParams.FLAG_FULLSCREEN | 
      WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | 
      WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | 
      WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); 
lock.release(); 

我正在使用服務來喚醒設備,但它似乎不起作用。

回答