You mean this?
B4X:Dim pm As PackageManager versionCode=pm.GetVersionCode ("yourApp") versionString=pm.GetVersionName("yourApp")
Sub Activity_Create(FirstTime As Boolean)
SendVersionRequest("anywheresoftware.b4a.b4abridge")
End Sub
Sub SendVersionRequest(packagename As String)
Dim j As HttpJob
j.Initialize("version", Me)
j.Download2("https://play.google.com/store/apps/details", Array As String("id", packagename))
End Sub
Sub VersionComplete(s As String)
Dim m As Matcher
m = Regex.Matcher("softwareVersion\" & QUOTE & ">([^<]+)</dd>", s)
If m.Find Then
Log("version = " & m.Group(1)) 'VERSION FOUND
Else
Log("version not found")
End If
End Sub
Sub JobDone (Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
If Job.JobName = "version" Then
VersionComplete(Job.GetString)
End If
Else
Log("Error: " & Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
Sorry, I mean the VersionCode of the App on the google App storeB4X:log(Application.VersionCode)
Sub Process_Globals
'------------------------------------------------------------------------------
' Download the current version number from Google and see if same as us
'------------------------------------------------------------------------------
Private gHttpVersionJob As HttpJob
Public gGoogleStoreListingAddress As String = "https://play.google.com/store/apps/details?id=com.BOBs.BBS"
end sub
Public Sub Service_Create
gHttpVersionJob.Initialize("version_check", Me)
gHttpVersionJob.Download(gGoogleStoreListingAddress)
end sub
Public Sub JobDone (Job As HttpJob)
If Job.JobName = "version_check" Then
If Job.Success Then
Dim m As Matcher = Regex.Matcher("softwareVersion\" & QUOTE & ">([^<]+)</div>", Job.GetString)
If m.Find Then
Dim CurrentVersion As String = m.Group(1)
CurrentVersion = CurrentVersion.Trim
#if Debug
Log("Version[" &gVersionName &"] CurrentVersion[" &CurrentVersion &"]")
#end if
gDifferentVersion = CurrentVersion
gDifferentVersionAvailable = Not(gVersionName.EqualsIgnoreCase(CurrentVersion))
' gNewVersionAvailable = Not(gVersionName.EqualsIgnoreCase(CurrentVersion))
'
' ToastMessageShow("NewerVersion:" &gNewVersion &" - " &gNewVersionAvailable, True)
End If
End If
end if
end sub
This code parses Google Play html and searches for the version:
B4X:Sub Activity_Create(FirstTime As Boolean) SendVersionRequest("anywheresoftware.b4a.b4abridge") End Sub Sub SendVersionRequest(packagename As String) Dim j As HttpJob j.Initialize("version", Me) j.Download2("https://play.google.com/store/apps/details", Array As String("id", packagename)) End Sub Sub VersionComplete(s As String) Dim m As Matcher m = Regex.Matcher("softwareVersion\" & QUOTE & ">([^<]+)</dd>", s) If m.Find Then Log("version = " & m.Group(1)) 'VERSION FOUND Else Log("version not found") End If End Sub Sub JobDone (Job As HttpJob) Log("JobName = " & Job.JobName & ", Success = " & Job.Success) If Job.Success = True Then If Job.JobName = "version" Then VersionComplete(Job.GetString) End If Else Log("Error: " & Job.ErrorMessage) ToastMessageShow("Error: " & Job.ErrorMessage, True) End If Job.Release End Sub
Requires HttpUtils2 modules.
Google keep changing the code in the PS.i'm sorry, but there alre lost some "DIM"..
and it don' t work as it is..
#VersionName : B*Bs-v3.07
Dim Data As String = Job.GetString
Dim IndexToCV As Int = Data.IndexOf(">Current Version<") ' Find Current Version in PS Page
If IndexToCV <> -1 Then
Data = Data.SubString(IndexToCV)
Dim IndexToBBS As Int = Data.IndexOf("B*Bs-v") ' Find Lead In to my Apps Version Number
If IndexToBBS <> -1 Then
Data = Data.SubString(IndexToBBS)
Dim IndexToEnd As Int = Data.IndexOf("<") ' The < is end of data.
If IndexToEnd <> -1 Then
Dim CurrentVersion As String = Data.SubString2(0, IndexToEnd)
CurrentVersion = CurrentVersion.Trim
gDifferentVersion = CurrentVersion
gDifferentVersionAvailable = Not(gVersionName.EqualsIgnoreCase(CurrentVersion))
End If
End If
End If
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?