0

I installed emulator for Marshmallow (MNC) but when I call Build.VERSION.SDK_INT it's returning to me 22. It has the functionality of MNC because it has runtime permissions etc and the calls work but it's just the build version that's off. How can this be resolved.

So to be clear, the code Build.VERSION.SDK_INT returns 22 on a api 23 emulator, why?

Marlon
  • 1,839
  • 2
  • 19
  • 42
j2emanue
  • 60,549
  • 65
  • 286
  • 456

1 Answers1

1

I think it depends on the Preview version on the emulator. I had the same effect on my Nexus 6 device. After M Preview 3 update the correct version (23) was returned, for former versions it was 22.

My workaround was to check for RELEASE attribute, which was "M" and on Preview 3 "Marshmallow" will be returned.

Thomas R.
  • 7,988
  • 3
  • 30
  • 39
  • Build.VERSION.RELEASE.equals("M") – Thomas R. Oct 08 '15 at 13:44
  • Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1 looks better but if lolipop gets a another MR it would break what im trying to do. I'd take your way but im not sure that in production release is "M". how do i know ? – j2emanue Oct 08 '15 at 14:01
  • and do you think Build.VERSION.SDK_INT > 22 makes better since ? – j2emanue Oct 08 '15 at 14:13
  • For your emulator you can check for release "M", but for release APK you can check version > 22. I don't think that there are so many devices running on Preview 1 or 2 of M. – Thomas R. Oct 08 '15 at 14:18