Hi everyone, i'm developing an Application that is set to be device-owner (for kiosk purposes) and it also signed with the device producer (so it is a system app).
This app is already able to trigger the installation of other apks with this intent based code:
' RequestInstallApp Class'
Now, the problem is that I need to SELF-UPDATE my application but, I do not know why exactly the intent is ignored.
Is there any way to do it? I read on the internet that today must be used the "PackageManager" to do these things
https://stackoverflow.com/a/73986373/10781209 (in this post you can also find a Java example for it, if needed)
Thanks in advance for the help
This app is already able to trigger the installation of other apks with this intent based code:
B4X:
Public Sub SendInstallIntent(apk_filename As String) As ResumableSub
Log("Install Intent")
If (File.Exists(xui.DefaultFolder, apk_filename)) Then
Dim ria As RequestInstallApp 'this is the name of the class
ria.Initialize(apk_filename)
tmrUpdateTimeout.Enabled = True
Wait For (ria.Install) Complete (Unused As Boolean)
tmrUpdateTimeout.Enabled = False
Return True
Else
Return False
End If
End Sub
' RequestInstallApp Class'
B4X:
[...]
Public Sub Install As ResumableSub
Wait For (File.CopyAsync(XUI.DefaultFolder, apk_filename, Starter.Provider.SharedFolder, apk_filename)) Complete (Success As Boolean)
Dim i As Intent
If phone.SdkVersion >= 24 Then
i.Initialize("android.intent.action.INSTALL_PACKAGE", Starter.Provider.GetFileUri(apk_filename))
i.Flags = Bit.Or(i.Flags, 1) 'FLAG_GRANT_READ_URI_PERMISSION
Else
i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(Starter.Provider.SharedFolder, apk_filename))
i.SetType("application/vnd.android.package-archive")
End If
'TODO - C'è da vedere come e se funziona
StartActivityForResult(i)
Wait For ion_Event (MethodName As String, Args() As Object)
Log(MethodName)
For Each o In Args
Log(o)
Next
Return True 'TODO
End Sub
[...]
Now, the problem is that I need to SELF-UPDATE my application but, I do not know why exactly the intent is ignored.
Is there any way to do it? I read on the internet that today must be used the "PackageManager" to do these things
https://stackoverflow.com/a/73986373/10781209 (in this post you can also find a Java example for it, if needed)
Thanks in advance for the help