elL
elL

Reputation: 777

Android - Allow Application to be Launched by other Application

I have an application that should be launched by other application. It can be launched by its own but it could also be launched from other application. So we have AppA and AppB. AppB could be launched from AppA.

From what I know, AppA could do this:

        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.setComponent(new ComponentName("com.mypackage.myapp","com.mypackage.myapp.MyActivity"));
        startActivity(intent);

The MyActivity is the activity of AppB.

Although I was able to launched AppB from AppA, my question is, is there any other configurations needed in AppB like in its Manifest? Or are there requirements do i have to keep in mind when invoking an Application from another Application?

If none, in this case, only AppA will do the work?

Upvotes: 2

Views: 1522

Answers (2)

Nargis
Nargis

Reputation: 4787

You can define an intent filter in the manifest of the app to be launched.App B in your case. The same Intent filter then can be used by the AppA that has to launch this AppB. This is called explicit intent. In future if any other app also wants to launch your AppB ,it can use the same intent filter. More on this.

Upvotes: 1

Gabe Sechan
Gabe Sechan

Reputation: 93589

ANy exported activity can be launched by any other activity that knows its name. Nothing special needed. An activity can be exported by putting exported=true in the activity tag in the manifest, or by having any intent filter on it (such as making it the launcher app for this app).

Upvotes: 1

Related Questions