I am struggling to find a simple example of launching another application on Android using an intent. I have looked into the sample applications of SendIntent and ReceiveIntent but they are more complicated than what I need. I've tried a few code examples based on Android examples but I am struggling to find out if I have a permission issue or something else. Something I have come across recently is that sometimes you need to manually edit the AndroidManifest.template.xml.
I tried this first changing the ACTION_VIEW to CATEGORY_LAUNCHER from the example. The application seems to fail always with the "Receiver not found" which means it is not finding the package at all that I needed to launch
procedure TForm1.SendTextViaIntent(const AText: string);
var
Intent: JIntent;
begin
Intent := TJIntent.Create;
Intent.setAction(TJIntent.JavaClass.CATEGORY_LAUNCHER);
if MainActivity.getPackageManager.queryIntentActivities(Intent, TJPackageManager.JavaClass.MATCH_ALL).size > 0 then
MainActivity.startActivity(Intent)
else
ShowMessage('Receiver not found');
end;
After some struggling I got something that works based on accepted Android code.
There is also a requirement for the correct permissions to be set on the manifest, this can be done under Application->Uses Permissions, The Query all packages permission needs to be set to True. You can call any application on the device that has launcher capabilities.
The code below with the appropriate uses should suffice and tests out fine with SDK 32 I am using.
Additionally to confirm the package name you want to target on the device, you can run this command from your SDK platform-tools folder:
You should be able to use whatever is listed after
base.apk=