Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 295
Ritwik Dey Avatar asked Mar 26 '13 12:03

Ritwik Dey


People also ask

How do I launch an Android app from another app?

Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.

How do you launch an activity that is part of some other application?

If both application have the same signature (meaning that both APPS are yours and signed with the same key), you can call your other app activity as follows: Intent LaunchIntent = getActivity(). getPackageManager(). getLaunchIntentForPackage(CALC_PACKAGE_NAME); startActivity(LaunchIntent);

How can two different Android applications interact?

Android inter-process communication At the simplest level, there are two different ways for apps to interact on Android: via intents, passing data from one application to another; and through services, where one application provides functionality for others to use.


1 Answers

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).

like image 118
Rick77 Avatar answered Nov 15 '22 01:11

Rick77