閑話少說,直接上代碼
/**
* APP 工具類
*
* @author chenxuxu
* @date 2018/2/10
*
*/
public class AppUtils {
/**
* 跳轉(zhuǎn)到應(yīng)用商店評分
*
* @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) {
// 如果沒有該應(yīng)用商店,則顯示系統(tǒng)彈出的應(yīng)用商店列表供用戶選擇
goAppShop(context, myAppPkg, "");
}
}
}
查看應(yīng)用商店的包名,可以使用當(dāng)前Activity APP 查看,或者將該應(yīng)用商店的 apk 下載,拖到 android studio 查看包名;