Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - How to start third party app with package name?

I am wondering how to start an another app from my app using package name.

I have package name in string format like

String pkgName = "com.example.appName";

That is why i am unable to fetch class name or any other valuable details from it which i can use to make a proper intent to start an activity.

Any idea how to solve this problem. Please Help!!

Thanks.

like image 800
Varundroid Avatar asked Apr 30 '11 08:04

Varundroid


1 Answers

well, you don't want to fetch ANY class name. What you want to do is to create an Intent out of this package name with Activity's that can be launched (they need to have specific category). In a single line, what you need to do is:

startActivity(getPackageManager().getLaunchIntentForPackage("com.example.appName"));

Check the documentation for PackageManager.getLaunchIntentForPackage. Generally speaking, PackageManager has a lot of interesting methods for launching apps. Here is my blog entry doing exactly that for multiple packages.

like image 125
Ilya Saunkin Avatar answered Sep 21 '22 13:09

Ilya Saunkin