DevicePerformance

interface DevicePerformance


Reports the media performance class of the device.

Create an instance of DevicePerformance in your android.app.Application.onCreate and use the mediaPerformanceClass value any time it is needed.

class MyApplication : Application() {

    private lateinit var devicePerformance: DevicePerformance

    override fun onCreate() {
        devicePerformance = DevicePerformance.create(applicationContext)
    }

    fun doSomeThing() {
        when {
            devicePerformance.mediaPerformanceClass >= Build.VERSION_CODES.S -> {
                // Provide the most premium experience for highest performing devices
            }
            devicePerformance.mediaPerformanceClass == Build.VERSION_CODES.R -> {
                // Provide a high quality experience
            }
            else -> {
                // Remove extras to keep experience functional
            }
        }
    }
}

Summary

Public fields

abstract int

The media performance class of the device or 0 if none.

Public fields

mediaPerformanceClass

abstract int mediaPerformanceClass

The media performance class of the device or 0 if none.

If this value is not 0, the device conforms to the media performance class definition of the SDK version of this value. This value is stable for the duration of the process.

Possible non-zero values are defined in Build.VERSION_CODES starting with VERSION_CODES.R.

Defaults to VERSION.MEDIA_PERFORMANCE_CLASS