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

前端 未结 1 1101
一整个雨季
一整个雨季 2021-01-18 05:06

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.         


        
相关标签:
1条回答
  • 2021-01-18 05:39

    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.

    0 讨论(0)
提交回复
热议问题