Files
Lanterna_H/updateAvailable.bas
Jose Alberto Guerra Ugalde 37426d7adb - VERSION 4.07.20
- Se cambio la base de datos que se manda al FTP, por error se estaba mandando desde "DirAssets" y debe de ser "DirInternal".
2024-07-22 20:09:27 -06:00

77 lines
2.4 KiB
QBasic

B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Activity
Version=12.8
@EndOfDesignText@
Sub Process_Globals
' Private Root As B4XView 'ignore
' Private xui As XUI 'ignore
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.
End Sub
'You can add more parameters here.
'Public Sub Initialize As Object
' Return Me
'End Sub
'This event will be called once, before the page becomes visible.
Sub Activity_Create(FirstTime As Boolean)
' Root = Root1
'load the layout to Root
Activity.Color = Colors.Transparent
End Sub
Sub Activity_Resume
Try
Do While Not(CanRequestPackageInstalls)
MsgboxAsync($"Por favor permita que ${Application.PackageName} instale actualizaciones"$, "Instalar actualización")
Wait For Msgbox_Result(Result As Int)
Dim in As Intent
in.Initialize("android.settings.MANAGE_UNKNOWN_APP_SOURCES", "package:" & Application.PackageName)
StartActivity(in)
Loop
Catch
Log("updateAvailable() Error - " & LastException.Message)
End Try
If appUpdater.newApp.update Then
ofreceActualizacion
Else
sinActualizacion
End If
End Sub
'////////////////////////////////////////////////////////////////////////////////////////////
'//// Esta es una actividad usada por el servicio appUpdater para mostrar notificaciones
'//// cuando hay alguna actualizacion de apk.
'////////////////////////////////////////////////////////////////////////////////////////////
public Sub CanRequestPackageInstalls As Boolean
' // https://www.b4x.com/android/forum/threads/version-safe-apk-installation.87667/#content
Dim ctxt As JavaObject
ctxt.InitializeContext
Dim PackageManager As JavaObject = ctxt.RunMethod("getPackageManager", Null)
Return PackageManager.RunMethod("canRequestPackageInstalls", Null)
End Sub
Sub ofreceActualizacion
If Msgbox2(appUpdater.newApp.newMsg,"Actualización disponible","Actualizar","","Cancelar",Null) = DialogResponse.Positive Then 'ignore
' StartService(DownloadService)
CallSubDelayed(appUpdater, "download_newApk")
End If
CallSubDelayed(Main, "ocultaProgreso")
StartActivity(Main)
' Activity.Finish
' B4XPages.ShowPage("Login")
End Sub
Sub sinActualizacion
Msgbox(appUpdater.newApp.okMsg, "Aplicación al corriente") 'ignore
CallSubDelayed(Main, "ocultaProgreso")
StartActivity(Main)
' B4XPages.ShowPage("Login")
End Sub