mirror of
https://github.com/KeymonSoft/Lanterna_H.git
synced 2026-04-17 21:06:16 +00:00
- Se agregaron archivos.
This commit is contained in:
77
updateAvailable.bas
Normal file
77
updateAvailable.bas
Normal file
@@ -0,0 +1,77 @@
|
||||
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","Si","","No",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
|
||||
Reference in New Issue
Block a user