Ritwik Dey
Ritwik Dey

Reputation: 609

Opening an Android application within another

I am trying to open a different, already installed android application within another, on click of a button. The new application should be opened in a part of the screen within the calling application.

Currently, my code creates a new intent and runs the called application in that. the calling application disappears. Here's my code:

        b.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            PackageManager pm = getPackageManager();
            Intent intent = pm.getLaunchIntentForPackage("com.ritwik.camera");
            startActivity(intent);
        }

    });

Ideally, it should open as a part of the same screen, without sidelining the parent(calling) application. How do I do that?

Upvotes: 6

Views: 251

Answers (3)

Entreco
Entreco

Reputation: 12900

As far as I know, this is NOT possible. You can only launch the new activity, but you have no control of it.

EDIT: Some devices offer this possibility using Cornerstone or similar frameworks, but I haven't seen an option for developers to use this for their own apps.

Upvotes: 1

CommonsWare
CommonsWare

Reputation: 1007554

The new application should be opened in a part of the screen within the calling application.

This is not possible with conventional third-party application UIs.

AFAIK, the split-screen feature (Adaptive UI) is supported from Android 3.0 onwards.

That has nothing to do with embedding the UI of third-party apps into your own.

So I didn't get what you meant to say by "it's not possible with the current version of the OS"

It is not available on any stock version of Android released up through March 26, 2013 at 9:50am Eastern Time.

Certain device manufacturers, like Samsung, have extended Android with multi-window capabilities. However, the control over those windows lies with the user and the (modified) OS. Unless there is something in their S-Pen SDK for this, you have no way of starting another window.

Android also has RemoteViews, which is a means of passing a simplified UI between processes. Using this, it is possible for one app to embed RemoteViews published by another app. You see this with app widgets on the home screen, for example. However, both apps have to be written with this in mind, such as an app publishing an AppWidgetProvider to supply app widgets to home screens.

Upvotes: 1

Rick77
Rick77

Reputation: 3221

When you start an Intent to execute another application (i.e. because you are implementing a launcher or a main menu replacement) you are actually asking android to execute the application identified with a specific package (or the one satisfying some specific constraints, like the ability to handle images, videos, etc), without any clue or reference about the Activities it contains (nor the ability to get any...).

Therefore I don't think that what you are trying to achieve is possible with the current version of the OS (unless some vendor is providing extensions to do just that, see the comment by Pratik).

Upvotes: 3

Related Questions