I am trying to update a mobile app I am working on without additional user input. The app is supposed to run without any users having access to the device and I need a way to update it. Since it will run on dozens of devices at once, just manually swapping it out is sadly not an option, as is making use of the PlayStore.
So far I have this code that allows me to initiate the update, but the user still needs to confirm it each time.
procedure TForm1.StartActivityA(const AFileName: string);
var
Intent: JIntent;
Data: Jnet_Uri;
begin
try
Intent := TJIntent.Create;
Intent.setAction(TJIntent.JavaClass.ACTION_VIEW);
Intent.setFlags(TJIntent.JavaClass.FLAG_GRANT_READ_URI_PERMISSION);
Data := TAndroidHelper.JFileToJURI(TJFile.JavaClass.init(StringToJString(AFileName)));
Intent.setDataAndType(Data, StringToJString('application/vnd.android.package-archive'));
TAndroidHelper.Activity.startActivity(Intent);
except
on E: Exception do
begin
TDialogService.ShowMessage(e.message);
end;
end;
end;
Since the devices the app is supposed to run on won't be accessible for user input, I am searching for a solution that allows me to do what I described (preferable while also closing and restarting the app, but I haven't gotten that far yet. Any pointers towards that would also be appreciated).
I found this post and this post about installing/updating an app on Android silently, but I can't figure out how to execute the commands in Delphi code. This one makes it look like it might be possible to do it with the code I have now, if the device is rooted, but I am not sure I understand it correctly.
And as far as I understand it, executing commands like this requires the device to be rooted. Is that correct?
Is this the correct approach or is there another one (ideally without the need to root the device, but I can manage, if there is no other way)?