I am developing an Android accessibility app in Kotlin. I want to provide full-screen magnification for users with visual impairments.
I use AccessibilityService.MagnificationController to set the magnification scale to 1.5. It works initially, but when I swipe to the Android home screen, the magnification resets to 1.0. The accessibility service remains enabled and connected.
I tried restoring the magnification once after detecting the reset. The API returns true, and the screen briefly becomes magnified again, but then returns to normal size.
Relevant Kotlin code:
val config = MagnificationConfig.Builder()
.setMode(MagnificationConfig.MAGNIFICATION_MODE_FULLSCREEN)
.setScale(1.5f)
.setActivated(true)
.build()
val result = magnificationController
.setMagnificationConfig(config, true)
Log.d("Visionplus", "Result = $result")
The magnification change listener initially reports a scale of 1.5, but reports 1.0 after switching to the home screen.
Accessibility service XML configuration:
Environment:
Android 15
Pixel 7 emulator
Kotlin and Android Studio
Full-screen magnification mode
My question:
How can my AccessibilityService maintain full-screen magnification after switching to the Android home screen, if Android permits this? Is there a recommended way to use MagnificationController to handle magnification changes without repeatedly resetting the zoom?
Thank you for your help. I am new to Android development, so a simple explanation would be appreciated.