1

I know that I can get the minSdkVersion of an app from ApplicationInfo object on API 24+. But is it possible on earlier APIs(as described in documentation). If there is no way, can someone tell me any alternative?

Ragib
  • 107
  • 7

1 Answers1

3

Getting minSdkVersion of app before 24 is not possible as their is no api is been exposed for the same.

But you can use this to get the same.

You just need to declare it in your gradle like this

defaultConfig {
    minSdkVersion 16
    buildConfigField "int", "MIN_SDK_VERSION", "$minSdkVersion.apiLevel"
}

Then whenever you want to use the same, you can access it as follow

BuildConfig.MIN_SDK_VERSION
Punit Sharma
  • 2,951
  • 1
  • 20
  • 35
  • I know that. But I wanted a way to get minSdkVersion for all apps on the device, that is why i am saying "from ApplicationInfo Object". Can you pls answer? – Ragib Aug 07 '18 at 10:26
  • Ok, I don't think that is possible even though as you are trying to get info of other apps. Might be a dirty hack can help but not aware of any :) – Punit Sharma Aug 07 '18 at 12:28