0

According to link, I have tried the following code

int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= android.os.Build.VERSION_CODES.FROYO){
    // Do something for froyo and above versions
} else{
    // do something for phones running an SDK before froyo
}

But it only gets the current API version of the current package. Is there a way for me to query other packages API versions through other means?

Community
  • 1
  • 1
rexer
  • 101
  • 1
  • 3
  • 14
  • 2
    it give you the API version of the device OS. what are you trying to achieve? – Praful Bhatnagar Nov 02 '12 at 09:32
  • Sorry, mixed up the title a little – rexer Nov 02 '12 at 09:33
  • So what are you trying to achieve? – Praful Bhatnagar Nov 02 '12 at 09:35
  • Which means i want to know the API version of specific application in my Android System as i am currently using package manager to retrieve the package names – rexer Nov 02 '12 at 09:36
  • what have you tried. Were you able to fetch the list of package's in the system? – Praful Bhatnagar Nov 02 '12 at 09:37
  • Yes, my specific problem is because i have to do certain stuffs for API level < 4 and certain stuffs for API level > 4 above because of the android.WRITE_EXTERNAL_STORAGE permission that i have to detect – rexer Nov 02 '12 at 09:43
  • Ok let me get it correct.. You want to enable/disable some feature of your app based on the SDK level of the device. for this your check should work fine.. What do you want to achieve by getting the SDK level of other packages? – Praful Bhatnagar Nov 02 '12 at 09:58

1 Answers1

0

But it only gets the current API version of the current package.

No, it gets the API level of the operating system that is running on the device.

Is there a way for me to query other packages API versions through other means?

There is no such concept in Android.

Which means i want to know the API version of specific application in my Android System as i am currently using package manager to retrieve the package names

There is no such concept in Android.

Yes, my specific problem is because i have to do certain stuffs for API level < 4 and certain stuffs for API level > 4 above because of the android.WRITE_EXTERNAL_STORAGE permission that i have to detect

You are welcome to "do certain stuffs" within your app based on the device's API level, using code like you have in your question. Every other app is welcome to do its own "certain stuffs" based on the device's API level.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491