保持屏幕常亮


保持屏幕常亮

activity中加入一行代码:

1
2
3
4
5
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.c_bb);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}