标签:屏幕唤醒
第一步: 首先添加权限:
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
第二步:代码实现如下:
public class ScreenActivity extends Activity { PowerManager powerManager = null; WakeLock wakeLock = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.main); powerManager = (PowerManager)this.getSystemService(this.POWER_SERVICE); wakeLock = this.powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "My Lock"); } @Override protected void onResume() { super.onResume(); wakeLock.acquire(); } @Override protected void onPause() { super.onPause(); wakeLock.release(); } }最后说明:在不同的生命周期调用WakeLock函数可以使系统正常运行(如果Activity结束没有调用WakeLock.release,则屏幕会一直常亮)。
Android保持屏幕常亮唤醒状态,布布扣,bubuko.com
标签:屏幕唤醒
原文地址:http://blog.csdn.net/loongggdroid/article/details/25035059