Reputation: 6296
My boss asked me to prove that my application behaves properly when summoned by another application (dunno why he asked that).
So I have two apps here, one launches a second one. How I launch the specific app I want? Using Intent launch seemly any generic app that reaches a certain goal, not the app I really want.
Upvotes: 0
Views: 580
Reputation: 569
Create one Intent using the following code
When you know the particular component(activity/service
) to be loaded
Intent intent = new Intent();
intent.setClass("className/package name");
start<Activity/Service>(intent);
When we do not have the idea which class to load and we know the Action to be perform by the launched application we can go with this intent.
Action needs to set, and the Android run time fallows the intent Resolution technique
and list out(one or more components) the components to perform the action. from the list out components (if more than one), user will get the chance to launch his chosen application
Upvotes: 0
Reputation: 8158
Give this a try.
Intent secondIntent = new Intent();
secondIntent.setAction(Intent.ACTION_MAIN);
secondIntent.setClassName("com.example", "com.example.YourSecondApp");
startActivity(secondIntent);
I should point out that com.example
should be the package of your second application (the one you want to call) and com.example.YourSecondapp
is the class name where you have your onCreate() method.
Upvotes: 3
Reputation: 5447
Intent secondApp = new Intent("com.test.SecondApp");
startActivity(secondApp);
Check out for more examples http://developer.android.com/resources/faq/commontasks.html#opennewscreen
Upvotes: 0