I am new to Android development. How can I prevent Android blocking when my application is in focus? When my application is out of focus, I want to guarantee that android os will have its default behavior.
use
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
you can do it using
Activity.getWindow (). AddFlags ().
private PowerManager mPowerManager; private WakeLock mWakeLock; Write this in OnCreate // Get an instance of the PowerManager mPowerManager = (PowerManager) getSystemService(POWER_SERVICE); // Create a bright wake lock mWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK| PowerManager.ACQUIRE_CAUSES_WAKEUP, getClass() .getName()); Write this in onResume mWakeLock.acquire(); write this in onPause mWakeLock.release();