Android禁止屏幕休眠

<uses-permission android:name="android.permission.WAKE_LOCK" />
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //要写在setContentView之前?
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,  WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.main);
}

 

发表回复

您的电子邮箱地址不会被公开。