2011年1月9日 星期日

WakeLock 範例

程式碼
Permission: wake_lock

PowerManager _pm=(PowerManager)this.getSystemService(Context.POWER_SERVICE);
WakeLock _wakeLock=_pm.newWakeLock(PowerManager.FULL_WAKE_LOCK|PowerManager.ACQUIRE_CAUSES_WAKEUP, "My Tag");

_wakeLock.acquire();
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
_wakeLock.release();
_wakeLock=_pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "My Tag");
_wakeLock.acquire();
_wakeLock.release();

沒有留言: