First of all, you must remember that 4k is just a resolution, but you must also remember about bitrate.
Here is a way to check the resolution / bit rate compatibility on a specific device:
boolean areSizeAndRateSupported (int width, int height, double frameRate)
https://developer.android.com/reference/android/media/MediaCodecInfo.VideoCapabilities.html#areSizeAndRateSupported(int,%20int,%20double)
There also:
isSizeSupported(int width, int height)
The only drawback of these methods is that it is supported from API level 21.
You can also test the capabilities of the codec using this method:
MediaCodecInfo.VideoCapabilities.getVideoCapabilities()
https://developer.android.com/reference/android/media/MediaCodecInfo.CodecCapabilities.html#getVideoCapabilities ()
But, as far as I know, they can return lower resolution than are actually supported.
On the other hand, in your case, devices below android lollipop are most likely not fast enough to play 4k video. Or even if they can, their resolution is too low to get any benefit from 4k resolution.
So, in my opinion, the most elegant solution is to assume that 4k is not supported below android 5.0 and uses the above method to check whether it supports on Android 5.0+.
Makalele
source share