跳转到其他APP

/** * 根据 包名和Activity跳转到目标应用 *

  • @param goToAppPackage 包名
  • @param goToAppActivity Activity cls
  • @param hint 跳转失败的提示信息
    */
    public void goToApp(String goToAppPackage, String goToAppActivity, String hint) {
    if (goToAppPackage.isEmpty() || goToAppActivity.isEmpty()) {
    ToastUtil.showShort(FragmentActivityMain.this, "跳转失败");
    } else {
    Intent isExist = getPackageManager().getLaunchIntentForPackage(goToAppPackage);
    if (isExist != null) {
    ComponentName com = new ComponentName(goToAppPackage, goToAppActivity);
    Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setComponent(com);
    this.startActivity(intent);
    } else {
    ToastUtil.showShort(FragmentActivityMain.this, hint);
    }
    }
    }

你可能感兴趣的:(跳转到其他APP)