Android Question SDK version command checking

Robert Valentino

Well-Known Member
Licensed User
Longtime User
I'm over 70 and forget what commands are available for what SDK versions.

I just used a command
B4X:
Dim paths() As Object = GetContext.RunMethod("getExternalFilesDirs", Array(Null))
on a device running OS 4.1.2 and SDK 16 now this command is not available until SDK 19

Now my min / max sdk in my manifest is set to
B4X:
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="29"/>

Is there a routine that will type check (not sure if that is the right term here) and let me know that commands are outside my min skd version (something I could put 'ignore on if I was checking the SDK around it)

I am sure with everyone being forced into moving up to SDK 30 that we all may run into these cases. I was lucky I was testing on a very old device so it caught this bug. But I am sure some can/will make it to production if we aren't careful

Any routine for this anyone know of? Is this something the IDE can check for us?

Not sure if I should put this in the Wish list, but if someone has a routine that we can run then please share.

BobVal

BobVal
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
I think you missed I said that (this command is not available until SDK 19) but the device I said was running API 16 (device running OS 4.1.2 and SDK 16)

Thing I forgot to do was
B4X:
if API >= 19 then getexternalfilesdir command else .... do something end if

If I could get something to pre-check my code to make sure I am not using commands without the API check around them.
Or maybe something to show me what API the commands I am using are.
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
I guess a lint checker is what I will start looking for? Must be something that we can say check my code against SDK n and have it report all calls that aren't available for SDK n

(note: n being any sdk number)
 
Upvote 0
Top