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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With