具体办法(二选一即可):
- onCreate
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); ...... }
- WakeLock
@Override protected void onStart() { super.onStart(); Log.d(TAG,"onStart()"); final PowerManager powerManager = Quantum6Telecom.getPowerManager(); if (powerManager != null && mWakeLock == null){ try { //PROXIMITY_SCREEN_OFF_WAKE_LOCK mWakeLock = powerManager.newWakeLock(PowerManager.ON_AFTER_RELEASE | PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, TAG); if (mWakeLock != null){ mWakeLock.acquire(); } } catch (Exception e) { // } } ...... }