PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV Mobile 2024 → update android app automatically
update android app automatically
Iniciado por Tiago, 14,mar. 2019 11:37 - 1 respuesta
Publicado el 14,marzo 2019 - 11:37
Hello everyone


I'm here to ask if someone knows how to download and install a new version of a apk.

FTPGets() only works in system folders and i can't download to an main storage folder.

Even if I mannually download the apk to downloads folder, Cant even install use ShellExecute()




thank you
Miembro registrado
123 mensajes
Popularité : +46 (46 votes)
Publicado el 18,marzo 2019 - 22:25
Try use HTTPREQUEST, and put your file in Public URL,


Example code (in use by myself)

WHEN EXCEPTION IN
//gs_url_endpoint is GLOBAL VARIABLE, Example = https://mydomain.com
PROGBAR_progreso..Visible = True //PROGBAR_progreso is a ProgressBar Control in Window.
HTTPProgressBar(PROGBAR_progreso)
Ok is boolean = HTTPRequest(gs_url_endpoint+"/updates/myapp.apk")
IF Ok = True THEN
s_filename is string
IF SysStatusExternalStorage(1) = sseAvailable THEN
s_filename = CompleteDir(SysDirExternalStorage(1, ssePublicDownload))+"apptmp.apk"
ELSE
s_filename = CompleteDir(fDataDir())+"apptmp.apk"
END
FileDownloading is Buffer = HTTPGetResult()
Ok = fSaveBuffer(s_filename,FileDownloading)

OkFile is boolean = fFileExist(s_filename)

IF Ok = True AND OkFile = True THEN
IF ShellExecute(s_filename) THEN
//code on ShellExecute OK
ELSE
PROGBAR_progreso..Visible = False
Error("Oops..","Error on Install App")
RETURN
END
ELSE
PROGBAR_progreso..Visible = False
Error("Error On Download File")
RETURN
END

ELSE
PROGBAR_progreso..Visible = False
Error("Error On Download File")
RETURN
END
DO
Error("Fatal Error",ExceptionInfo(errFullDetails))
RETURN
END


P.D: Files downloaded with FTP if it can be stored in SDCARD (Check the help)

--
Atte. Willian Fernando