欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Android 打开指定程序

程序员文章站 2022-06-04 08:51:22
...

Android App 打开指定程序


Core code:

Intent launchIntent = getPackageManager().getLaunchIntentForPackage(appFullName);

Sample

    private void openTheSpecificApp (){
    	String appFullName = "your app full name";
        Intent launchIntent = getPackageManager().getLaunchIntentForPackage(appFullName);
        if (launchIntent != null) {
            startActivity(launchIntent);//null pointer check in case package name was not found
        }
    }

Notice: appFullName should be the FULL NAME of that APP, like com.android.settings




核心代码:

Intent launchIntent = getPackageManager().getLaunchIntentForPackage(appFullName);

注意: appFullName 一定要是完整的app软件名字, 比如 com.android.settings




Enjoy coding!