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