Android Question Problems with intent INSTALL_PACAKGE pre Android 12

Lee Gillie CCP

Active Member
Licensed User
Longtime User
We have a self updater. Once the APK file is downloaded from our private website we start an activity to install it.
Dim i As Intent

Dim apkPath As String = "file://" & File.Combine(File.DirDefaultExternal, APKFileName)

Log("Installing from: " & apkPath)
If phone.SdkVersion >= 24 Then
File.copy(File.DirDefaultExternal, APKFileName, Starter.Provider.SharedFolder, APKFileName)

i.Initialize("android.intent.action.INSTALL_PACKAGE", Starter.Provider.GetFileUri(APKFileName))
i.Flags = Bit.Or(i.Flags, 1) 'FLAG_GRANT_READ_URI_PERMISSION
Else
Dim out As OutputStream
out = File.OpenOutput(File.DirRootExternal,APKFileName,False)
out.WriteBytes(bts, 0, bts.length)
out.Close

i.Initialize(i.ACTION_VIEW,apkPath )
i.SetType("application/vnd.android.package-archive")
End If


StartActivity(i)

ExitApplication
When this runs on Android 12 it works perfectly.
When this runs on Android 10 we are getting "There was a problem parsing the package" during install.

Yet on the same Android 10 tablet we are able to manually uninstall the app, download the APK with a browser, and open it and the installer works perfectly.

Why does the intent have issue, but when invoked from the file system it does not?
 
Top