Android Question Check Android Version

GMan

Well-Known Member
Licensed User
Longtime User
Hoi,

i am using the ToastMessageShow - lib and it works well.
Now i tested the app on a 2.1 Device, which causes an error when displaying the ToastMessage:
B4X:
InitializeToast
toast.Location = toast.CENTER
toast.Show4("Info","Hello," & CRLF & "Pressing any entry shows details",toast.INFO_ICON)

When i disable that, the 2.1 device works.

So the question is: can i make a request in a Try....Catch...End Try for the installed Android version and, in this case, if 2.1 do not dislpay the ToastMessage ?
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
Dim p As Phone
Log("PhoneSDK="&p.SdkVersion)
?
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
You can use this Subs too

B4X:
Sub GetSDK() As Int
    Dim p As Phone
    Return p.SdkVersion
End Sub
Sub GetSDKversion() As String
    Dim versions As Map
    versions.Initialize
    versions.Put(3,"1.5")
    versions.Put(4,"1.6")
    versions.Put(7,"2.1")
    versions.Put(8,"2.2")
    versions.Put(10,"2.3.3")
    versions.Put(11,"3.0")
    versions.Put(12,"3.1")
    versions.Put(13,"3.2")
    versions.Put(14,"4.0")
    versions.Put(15,"4.0.3")
    versions.Put(16,"4.1.2")
    versions.Put(17,"4.2.2")
    versions.Put(18,"4.3")
    versions.Put(19,"4.4.2")
    Dim p As Phone
    Return versions.Get(p.SdkVersion)
End Sub

B4X:
Log("SDK="&GetSDK) ' SDK=19 (on my Phone)
Log("SDKversion="&GetSDKversion) ' SDKversion=4.4.2 (on my Phone)
 
Upvote 0
Top