eyal
eyal

Reputation: 2409

calling activity from external Activity

I'd like to start an Activity which is not included in my original .apk. How can I do so? the other Activity is contained in another .apk which is previous version of the current application. Thanks, Eyal.

Upvotes: 1

Views: 5728

Answers (2)

gosr
gosr

Reputation: 4708

This method is good if you only know the package name:

PackageManager pm = getPackageManager();
Intent intent = pm.getLaunchIntentForPackage("com.the.other.app");
startActivity(intent);

Upvotes: 5

slhck
slhck

Reputation: 38740

I'd suggest you read through the Application Fundamentals first - as far as I'm concerned, you will have to use Intents:

As noted earlier, one activity can start another, including one defined in a different application. Suppose, for example, that you'd like to let users display a street map of some location. There's already an activity that can do that, so all your activity needs to do is put together an Intent object with the required information and pass it to startActivity(). The map viewer will display the map. When the user hits the BACK key, your activity will reappear on screen.

So, basically, you define a new intent (you should also take a look at the docs of the Intent class):

Intent myIntent = new Intent();
myIntent.setClassName("com.the.other.app", "com.the.other.app.activityName");
startActivity(myIntent);

Upvotes: 5

Related Questions