I want to install an apk from my app in android and I did try following
var
Path: JString;
Name: JString;
F: Jfile;
Intent: JIntent;
Path := StringToJString(System.IOUtils.TPath.GetSharedDownloadsPath);
Name := StringToJString('Test.apk');
F := TJfile.JavaClass.init(Path, Name);
Intent := TJIntent.Create();
Intent.setAction(TJIntent.JavaClass.ACTION_VIEW);
Intent.addFlags(TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK);
Intent.setDataAndType(TJnet_Uri.JavaClass.fromFile(F), StringToJString('application/vnd.android.package-archive'));
TAndroidHelper.Context.startActivity(Intent);
and I get android.os.FileUriExposedException: file:///storage/emulated/0/Download/Test.apk exposed beyond app through Intent.getData()
I did try to replase file:// to content:// through ReplaceString but no luck. I did also try following code in setDataAndType package installer starts but getting parsing error.
Intent.setDataAndType(TAndroidHelper.JFileToJURI( TJFile.JavaClass.init(StringToJString(System.IOUtils.TPath.Combine(System.IOUtils.TPath.GetPublicPath,'Test.apk')))),StringToJString('application/vnd.android.package-archive'));
Please help !!!