MixedAndroid开发Android开发

android APP 跳转到应用商店评分

2018-02-10  本文已影响161人  chenxuxu

闲话少说,直接上代码

/**
 * APP 工具类
 *
 * @author chenxuxu
 * @date 2018/2/10
 *
 */
public class AppUtils {

    /**
     * 跳转到应用商店评分
     *
     * @param context
     * @param myAppPkg
     * @param shopPkg
     */
    public static void goAppShop(Context context, String myAppPkg, String shopPkg) {
        if (TextUtils.isEmpty(myAppPkg)) {
            return;
        }

        try {
            Uri uri = Uri.parse("market://details?id=" + myAppPkg);
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            if (!TextUtils.isEmpty(shopPkg)) {
                intent.setPackage(shopPkg);
            }
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent);
        } catch (Exception e) {
            // 如果没有该应用商店,则显示系统弹出的应用商店列表供用户选择
            goAppShop(context, myAppPkg, "");
        }
    }
}

查看应用商店的包名,可以使用当前Activity APP 查看,或者将该应用商店的 apk 下载,拖到 android studio 查看包名;

上一篇 下一篇

猜你喜欢

热点阅读