10

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

keyboardsurfer
  • 14,541
  • 6
  • 59
  • 82
Pawan
  • 1,495
  • 2
  • 19
  • 28
  • In android you use an "intent" See: http://stackoverflow.com/questions/2780102/open-another-application-from-your-own-intent – James Becwar Nov 08 '11 at 04:46
  • Hi Jbecwar, I know this, even I have implemented this in one App, But in this case the another application in starts on the top of current application I want to start inside my app, justlike we start web browser. – Pawan Nov 08 '11 at 05:35
  • possible duplicate of [Use external application fragment/activity inside application](http://stackoverflow.com/questions/7726702/use-external-application-fragment-activity-inside-application) – George Stocker Nov 10 '11 at 13:41
  • 1
    did you found a solution to this issue? Thanks – haythem souissi Dec 17 '12 at 22:04

2 Answers2

0

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.

hcpl
  • 16,793
  • 7
  • 66
  • 71
0

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.

Community
  • 1
  • 1
Martin Y.
  • 671
  • 4
  • 5