This is driving me crazy since daays.
I imported all correct and still get “getAll” unresolved error on Android even so set all correct in the “build.gradle.kts”
`android {
namespace = “com.example.myapplication”
compileSdk = 34
defaultConfig {
applicationId = "com.example.myapplication"
minSdk = 26
targetSdk = 34
versionCode = code
versionName = "1.0"}`
Everything works so far with CamcorderProfile, but I get always an error that it is deprecated form 33 onwards… –> Android is really … How come a company decides to layoff a functionality and no one cares about a proper documentation and if it works?
Documentation of CamrecorderProfile:
https://developer.android.com/reference/kotlin/android/media/CamcorderProfile#getAll(kotlin.String,%20kotlin.Int)
It says to get all encoder back just use EncoderProfiles.getAll(cameraId, it)
There is even a ? behind, do not know why in case I go to EncoderProfiles (https://developer.android.com/reference/kotlin/android/media/EncoderProfiles) there is no such getAll…
Now the question to you, how can I solve the madness?
Thank you very much for all of your support.
My code below.
`import android.media.EncoderProfiles
@RequiresApi(Build.VERSION_CODES.S)
fun getAvailableEncoderProfiles(cameraManager: CameraManager, cameraId: String): List {
val characteristics = cameraManager.getCameraCharacteristics(cameraId)
val cameraDirection = characteristics.get(CameraCharacteristics.LENS_FACING)
if (cameraDirection == CameraCharacteristics.LENS_FACING_FRONT) {
// Front-facing camera, return only QUALITY_HIGH
return listOf(CamcorderProfile.QUALITY_HIGH).also {
Log.d("CameraApp", "Front-facing camera detected, using QUALITY_HIGH")
}
}
val qualities = listOf(
CamcorderProfile.QUALITY_8KUHD,
CamcorderProfile.QUALITY_4KDCI,
CamcorderProfile.QUALITY_2160P,
CamcorderProfile.QUALITY_1080P,
CamcorderProfile.QUALITY_2K,
CamcorderProfile.QUALITY_720P,
CamcorderProfile.QUALITY_480P,
CamcorderProfile.QUALITY_CIF,
CamcorderProfile.QUALITY_QVGA,
CamcorderProfile.QUALITY_QCIF,
CamcorderProfile.QUALITY_LOW,
CamcorderProfile.QUALITY_HIGH
)
val availableQualities = qualities.filter {
try {
EncoderProfiles.getAll(cameraId, it) != null
} catch (e: IllegalArgumentException) {
false
}
}
availableQualities.forEach { quality ->
Log.d("CameraApp", "EncoderProfiles available for quality: $quality")
}
return availableQualities
}`
getAll working as documented by Android
DrDree is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.