1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
public class AndroidWakeLock extends Activity {
WakeLock wakeLock;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
PowerManager powerManager =
(PowerManager)getSystemService(Context.POWER_SERVICE);
wakeLock =
powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK,
"Full Wake Lock");
}
@Override
protected void onResume() {
super.onResume();
wakeLock.acquire();
}
@Override
protected void onPause() {
super.onPause();
wakeLock.release();
}
}