How to open another application from current application on Android? – Different Approach
Opening an application from your own application is simple and you can find the solution everywhere like this :
Intent i = new Intent(Intent.ACTION_MAIN); i.setComponent(new ComponentName("app package name", "app launch activity's classname")); i.addCategory(Intent.CATEGORY_LAUNCHER); startActivity(i);
The problem here is that if you do not know the application’s launch activity’s classname, you can not open the application. Of course one can say that: “I can access this file from Package Manager – Application Info”. My answer will be : “Try and see :)”. ApplicationInfo sometimes returns null values which makes the developer crazy.
Here is my approach to this situation (getLaunchIntentForPackage) :
Intent i = new Intent(Intent.ACTION_MAIN); PackageManager manager = getPackageManager(); i = manager.getLaunchIntentForPackage("app package name"); i.addCategory(Intent.CATEGORY_LAUNCHER); startActivity(i);
Hope this also will help to you!
1 Comment to “How to open another application from current application on Android? – Different Approach”
Post comment
Blog Categories
- Actionscript (3)
- Air (4)
- Android (6)
- BLOG (4)
- Flex (3)
Recent Posts
- Using Button in ExpandableListView
- Showing flash objects in WebView
- Using Android library projects in custom builds
Archives
- June 2012
- December 2011
- October 2011
- September 2011
- July 2011
- June 2011
- August 2010
- June 2010
- May 2010
- March 2010

Posted by Ercan in
Aidan says:
Thank you so much! Heres the code i made from this:
Button bClock = (Button) findViewById(R.id.bOpenClock);
bClock.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent i = new Intent(Intent.ACTION_MAIN);
PackageManager managerclock = getPackageManager();
i = managerclock.getLaunchIntentForPackage(“com.android.deskclock”);
i.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(i);
}
});
One Question: Is there a way to failsafe if the application dosent exist??