My program looks like:
(Android 7.1.2, SdkVersion=25)
If phone.SdkVersion >= 24 Then
i.Initialize("android.intent.action.INSTALL_PACKAGE", GetFileUri(apkname))
i.Flags = Bit.Or(i.Flags, 1) 'FLAG_GRANT_READ_URI_PERMISSION
Else
i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(SharedFolder, apkname))
i.SetType("application/vnd.android.package-archive")
End If
StartActivity(i)
Nothing special. But my getfileuri throw an exception in the return line.
Private Sub GetFileUri (FileName As String) As Object
Dim FileProvider As JavaObject
Dim context As JavaObject
context.InitializeContext
FileProvider.InitializeStatic("android.support.v4.content.FileProvider")
Dim f As JavaObject
f.InitializeNewInstance("java.io.File", Array(SharedFolder, FileName))
Return FileProvider.RunMethod("getUriForFile", Array(context, Application.PackageName & ".provider", f))
End Sub
My file was here:
/data/user/0/b4a.selfupdater/files/shared/update.apk
But FileProvider.RunMethod() throw an exception:
error: Caused by: java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/b4a.selfupdater/files/shared/update.apk
Who said to them, that my file is in "/data/data/..." ?!
I had to make some change in the manifest!
Original:
Good:
It works now. But I don't know, that is some special what valid for this android device (X96mini), or valid for other type devices also?
Thanks Erel for the quick reply!