Android通过报名启动app

public void jumpToAppByPackage(final String packname) {

runOnUiThread(new Runnable() {

@Override

        public void run() {

PackageManagerpackageManager = getPackageManager();

            if (checkPackInfo(packname)) {

Intentintent =packageManager.getLaunchIntentForPackage(packname);

                startActivity(intent);

            }else {

Toast.makeText(MainActivity.this, getString(R.string.no_found_app) +packname, Toast.LENGTH_LONG).show();

            }

}

});

}

private boolean checkPackInfo(String packname) {

PackageInfo packageInfo =null;

    try {

packageInfo = getPackageManager().getPackageInfo(packname, 0);

    }catch (PackageManager.NameNotFoundException e) {

e.printStackTrace();

    }

return packageInfo !=null;

}

你可能感兴趣的:(Android通过报名启动app)