Category : android-11

I am working on a system app, where I want to know if power save mode is enabled or not. Currently I am trying to get using below code – final int lowPowerMode = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.LOW_POWER_MODE, -1); final int lowPowerModeSticky = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.LOW_POWER_MODE_STICKY, -1); if (lowPowerMode == 1 && lowPowerModeSticky == 1) { // means ..

Read more

I am using below code to enable immersive mode: final Window window = getWindow(); WindowCompat.setDecorFitsSystemWindows(window,false); WindowInsetsControllerCompat windowInsetsControllerCompat = new WindowInsetsControllerCompat(window,myContainer); windowInsetsControllerCompat.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars()); window.setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); In android 11 status bars and navigation bars stays visible, they do’t hide back again after some seconds. What is the solution? Source: Android..

Read more

When my app starts service from background there occurs log in the Logcat: ActivityManager: Foreground service started from background can not have location/camera/microphone access. And I am okay with that because it is known restriction in Android 11. How to programmatically determine whether my foreground service has access to location in Android 11? I want ..

Read more

Before updating my android device to Android 11, I was able to implement getMaxAmplitude() in that way using MediaRecorder: var amplitude: Double public void start() { if (mRecorder == null) { mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC) mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP) mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB) mRecorder.setOutputFile("/dev/null") try { mRecorder.prepare() } catch (IOException e) { e.printStackTrace() } mRecorder.start() amplitude = mRecorder.maxAmplitude() } } I saw this topic, ..

Read more