Ik zoek een mogelijkheid om een .apk bestand te installeren met code.
Ik zit hier naar te kijken:
https://stackoverflow.com/questions/...ly-new-version
En gebruik dit deel:
--------------------------------------------
Code:
procedure TForm1.Button5Click(Sender: TObject);
begin
StartActivity('MMSoft/Test.apk');
end;
procedure TForm1.StartActivity(const FileName: string);
var
Path: JString;
Name: JString;
F: Jfile;
Intent: JIntent;
begin
//rgineel:
//Path := StringToJString(System.IOUtils.TPath.GetDirectoryName(FileName));
//Name := StringToJString(System.IOUtils.TPath.GetFileName(FileName));
Path := StringToJString(Path_MMSoft + '/');
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);
Application.Terminate();
end;
--------------------------------------------
Helaas krijg ik deze foutmelding:
android.os.FileUriExposedException:
file:///storage/emulated/o/MMSoft/Test.apk
exposed beyond app through Intent.getData()
--------------------------------------------
Wat doe ik verkeerd en hoe is dit werkend te krijgen ?
Bookmarks