I want to launch any existing app of device inside a fragment. Can anyone please help me how can I do this.
Thanks & BR, Pawan
I want to launch any existing app of device inside a fragment. Can anyone please help me how can I do this.
Thanks & BR, Pawan
You can't just run code from other apps. Each app runs in it's own dalvik VM for security reasons. Of you want to interact with other apps you need to use the intent system. This allows programmers to define certain ways of interaction.
If you're talking about two apps you made yourself you could try to mimic the app in app scenario you ask for here by sharing resources with a shareduserid in the manifest of both apps and an intent to switch from one app to another. Not that I can think of a good use case for this...
Combine this with the second app having a transparent background and it should be possible to somehow hide the fact that another app was launched. Still can't think of a good use case though... Surprise me.
Well this is not possible for regular app, if you want to try it anyway, read this.
Otherwise, you can try to make a Home application (if this is your actual task), that filters intent by this:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
And then in your code you can fetch the apps like this:
List<ApplicationInfo> apps = context.getPackageManager().getInstalledApplications(0);
Display them as some sort of List or Grid, and when you handle a click, you can launch it as standalone app like this:
context.getPackageManager().getLaunchIntentForPackage(app.packageName);
Where app is ApplicationInfo. But of course you must filter the apps that have actual launch intent. :)
But then again about the starting them in your OWN app, I am not sure you can do it.
© 2022 - 2024 — McMap. All rights reserved.