I see some open-source flashlight apps (FlashDim , Flashlight-Tiramisu) that can control flash strength from Android version 13+, but these apps build using Kotlin and XML (not in jetpack compose). So I wanted to develop same type of app but the problem is, I cant control the flash strength from android 13, The error says it needs to be android 15+ (API 35+). Here’s a simple function that I want to share,
@RequiresApi(35)
fun getTorchStrengthValue(context: Context) : Int {
val cameraManager = ContextCompat.getSystemService(context, CameraManager::class.java) as CameraManager
val cameraId = cameraManager.cameraIdList[0]
val cameraCharacteristics = cameraManager.getCameraCharacteristics(cameraId)
val torchMaxLevel = cameraCharacteristics[CameraCharacteristics.FLASH_TORCH_STRENGTH_MAX_LEVEL] ?: -1
return torchMaxLevel
}
As it says, the required API 35, this same system is implemented in The Flashlight-tiramisu app, (maybe in different ways of course). But there is doesn’t require API 35.
How can I bypass that from my Jetpack-compose app??
1