super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
WindowManager.LayoutParams attrs;
attrs = getWindow().getAttributes();
// attrs.extend |= WindowManager.LayoutParams.EXTEND_IGNORE_HOME_KEY;
getWindow().setAttributes(attrs);
setContentView(R.layout.activity_main);、
如上代码,可在代码中搞定无标题、全屏、保持屏幕开启状态。
一般地,我们在manifest中搞定这些。