How to run or start application inside the fragment of Android?
Asked Answered
B

2

11

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

Bunce answered 8/11, 2011 at 4:29 Comment(3)
In android you use an "intent" See: #2780602Fraternity
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.Bunce
possible duplicate of Use external application fragment/activity inside applicationSinistrad
J
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.

Jugulate answered 18/9, 2013 at 23:41 Comment(0)
G
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.

Godred answered 27/4, 2016 at 8:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.