I have a very specialized POS application running on Android devices that would not qualify to be entered into the Play Store. These apps need to be updated whenever there are new features or bug fixes. I load the .apk on the website and call the following service:
The name of my app is was.apk
The servername is contained in the string variable Main.hostVersion that is in the Main activity
this will download the apk and start the install process
The name of my app is was.apk
The servername is contained in the string variable Main.hostVersion that is in the Main activity
this will download the apk and start the install process
B4X:
Sub Process_Globals
Dim host As HttpClient
Dim Request As HttpRequest
Dim Receive As String
Dim AppName As String
Dim hostaddress As String
End Sub
Sub Service_Create
AppName = "was.apk"
host.Initialize("host")
End Sub
Sub Service_Start (StartingIntent As Intent)
File.Delete(File.DirDefaultExternal,AppName)
Request.InitializeGet(Main.hostVersion & AppName)
Request.Timeout = 60000
host.Execute(Request, 1)
End Sub
Sub Service_Destroy
End Sub
Sub host_ResponseSuccess (Response As HttpResponse, TaskId As Int)
ToastMessageShow("Retrieving Update",True)
Receive = Response.GetAsynchronously("UpdateIT",File.OpenOutput(File.DirDefaultExternal,AppName,False),True,TaskId)
End Sub
Sub host_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
ToastMessageShow("Update Not Available At This Time!",True)
End Sub
Sub UpdateIT_StreamFinish(Success As Boolean, TaskId As Int)
Dim i As Intent
ToastMessageShow("Installing Update",True)
i.Initialize(i.ACTION_VIEW, "file://" & File.DirDefaultExternal & "/" & AppName)
i.SetType("application/vnd.android.package-archive")
StartActivity(i)
End Sub