Google has changed the layout a few times in the past.
I suggest to get rid of the problem by yourself.
When uploading a app to the playstore you can upload a small textfile with all relevant info to your webserver too.
Download the textfile using okhttputils when the app starts and compare if the app is uptodate or not.
Sub GetLine(idx As Int) As String
Dim text As List = File.ReadList(File.DirAssets,"VersionNumber.txt")
If text.IsInitialized And text.Size>=idx-1 Then
Return text.Get(idx-1)
End If
Return ""
End Sub
version = Application.VersionCode
'Log(GetLine(1))
If GetLine(1)=version Then
Else
MsgboxAsync("You are Currently using An Old version of the App please Unstall and install the Latest Version Thanks","App Old Version")
End If
is this one ok because from your explanation this is what i have managed to come up withB4X:log(Application.Version Code)
Sub GetLine(idx As Int) As String
Dim text As List = File.ReadList(File.DirAssets,"VersionNumber.txt")
If text.IsInitialized And text.Size>=idx-1 Then
Return text.Get(idx-1)
End If
Return ""
End Sub
dim version as String
version = Application.VersionCode
'Log(GetLine(1))
If GetLine(1)=version Then
Else
MsgboxAsync("You are Currently using An Old version of the App please Unstall and install the Latest Version Thanks","App Old Version")
End If
Here is a complete working code:
I tested it on 3 of my apps in the Playstore. However, there is a risk that Google will frequently change the layout of this Playstore webpage.B4X:'Activity module Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. End Sub Sub Globals 'These global variables will be redeclared each time the activity is created. 'These variables can only be accessed from this module. Dim PM As PackageManager Dim SourceText1 As String Dim Version1 As String Dim Version2 As String End Sub Sub Activity_Create(FirstTime As Boolean) Dim j As HttpJob Dim n, m As Long Dim Date1 As String j.Initialize("", Me) j.Download("https://play.google.com/store/apps/details?id=brainznl2.dsh") 'Change this to your own APK name Wait For (j) JobDone(j As HttpJob) If j.Success Then SourceText1=j.GetString n = SourceText1.IndexOf2("<span class=" & Chr(34) & "htlgb" & Chr(34) & ">",0) + 20 n = SourceText1.IndexOf2("<div class=" & Chr(34) & "IQ1z0d",n) + 18 n = SourceText1.IndexOf2("<span class=" & Chr(34) & "htlgb" & Chr(34) & ">",n) + 20 m = SourceText1.IndexOf2("</span>",n) If m>n Then Date1 = SourceText1.SubString2(n,m) n = SourceText1.IndexOf2("<span class=" & Chr(34) & "htlgb" & Chr(34) & ">",n) + 20 n = SourceText1.IndexOf2("<span class=" & Chr(34) & "htlgb" & Chr(34) & ">",n) + 20 n = SourceText1.IndexOf2("<span class=" & Chr(34) & "htlgb" & Chr(34) & ">",n) + 20 n = SourceText1.IndexOf2("<span class=" & Chr(34) & "htlgb" & Chr(34) & ">",n) + 20 n = SourceText1.IndexOf2("<span class=" & Chr(34) & "htlgb" & Chr(34) & ">",n) + 20 n = SourceText1.IndexOf2("<span class=" & Chr(34) & "htlgb" & Chr(34) & ">",n) + 20 m = SourceText1.IndexOf2("</span>",n) Version1 = PM.GetVersionCode(GetPackageName) If m>n Then Version2 = SourceText1.SubString2(n,m) If Version1<>Version2 Then Msgbox("Current version is: " & Version1 & CRLF & "Playstore version is: " & Version2 & CRLF & "Uploaded: " & Date1,"Your App version is out of date") Else Log("Error") End If j.Release End Sub Sub GetPackageName As String Dim r As Reflector Return r.GetStaticField("anywheresoftware.b4a.BA", "packageName") End Sub Sub Activity_Resume End Sub Sub Activity_Pause (UserClosed As Boolean) End Sub
Sub LoadCheckVersion (d As String) As ResumableSub
Log(d)
Dim jt As HttpJob
jt.Initialize("", Me)
jt.Download("http://kccug.com/KabojjaApp/HandlerVBCheckVersion.ashx")
'jt.GetRequest.Timeout = 3000' 10 seconds
Wait For (jt) JobDone(jt As HttpJob)
If jt.Success Then ' if job is success (http status code 200)
Dim RetVal As String
RetVal = jt.GetString
Log(RetVal)
If jt.GetString = "[]" Then
'MsgboxAsync("No Records to Upload Yet for: " & CustID ,"SMIS")
Return "Empty"
Else
Dim jp As JSONParser
jp.Initialize(jt.GetString)
'Log(jp) ' will pr
Log($"Token(${jp})"$)
Dim quotdt As List = jp.NextArray
For Each quotd As Map In quotdt
Log("CurrentVersion: " & quotd.Get("CurrentVersion"))
Log("ReleaseDate: " & quotd.Get("ReleaseDate"))
Next
Return "Good"
jt.Release
End If
End If
End Sub
Hi Syd,There is a simple solution: Just open the webpage of your app in the Playstore, e.g. one of my apps is: https://play.google.com/store/apps/details?id=brainznl2.dsh
and then use httpjob to download and read the source of this webpage and then "scrape" it.
There are two places where the version number is located: between <span class="htlgb"> and </span> and also after </script><script nonce= (between the square brackets)
Just compare this string to the actual version number in your code and then warn the user if it is not the same.
That's what I haveI just tried your link to the Playstore. For some reason it does not show any version number, also not in any webbrowser. Therefore my code reports that your version is "2.0 and up", which in fact is the required minimum Android version (i.e. the next item on the playstore webpage). Are you sure you have entered a version number in your app under the "Module attributes" behind "#VersionName:" before you uploaded your app to the Playstore?? My guess is that you only entered a number after "#VersionCode:".
Thanks, version name was empty.Did you check what I suggested in your B4A app? It should look someting like this:
B4X:#Region Module Attributes #FullScreen: False #IncludeTitle: True #ApplicationLabel: My Test App #VersionCode: 2 #VersionName: 1.21 #SupportedOrientations: unspecified #CanInstallToExternalStorage: False #End Region