procedure TformMain.OpenApp(PackageName, AppName : JString);
var
Intent : JIntent;
NativeComponent : JComponentName;
begin
Intent := TJIntent.Create;
Intent.setAction(TJIntent.JavaClass.ACTION_MAIN);
Intent.addCategory(TJIntent.JavaClass.CATEGORY_LAUNCHER);
NativeComponent := TJComponentName.JavaClass.init(PackageName, AppName);
Intent.addFlags(TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK or TJIntent.JavaClass.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
Intent.setComponent(NativeComponent);
SharedActivity.startActivity(Intent);
end;
Here is the function for listing the apps installed on the device:
function TformMain.GetActivityAppList: JList;
var
tempList : JList;
Intent : JIntent;
Manager : JPackageManager;
begin
Intent := TJIntent.Create;
Intent.setAction(TJIntent.JavaClass.ACTION_MAIN);
Intent.addCategory(TJIntent.JavaClass.CATEGORY_LAUNCHER);
Manager := SharedActivity.getPackageManager;
tempList := nil;
tempList := Manager.queryIntentActivities(Intent, 0);
Result := tempList;
end;
And you’ll have to download the demo itself to get the code for reading and caching the icon for each app.
Download the full source code for the Android app list launcher for Delphi XE7 Firemonkey.