发送包的名称以任何市场 [英] Send package name to any market

查看:94
本文介绍了发送包的名称以任何市场的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有一些话题与这个称号。但他们都只能与GOOGLEPLAY。结果
我希望让用户选择自己喜欢的市场。送包的名称推向市场,并得到结果。

i know there are some topics with this title. but all of them only works with GooglePlay.
i want to let users choose their favorite market. send package name to market and get results.

我也测试了这一点:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=com.android.example"));
startActivity(intent);

但这不是由一些市场支持。

but this is not supported by some markets.

推荐答案

您需要为亚马逊的Appstore及谷歌的单独的意图播放:

You need a separate intent for Amazon Appstore and Google Play:

code的该位计算出用来存储它从安装,然后尝试谷歌Play和亚马逊的Appstore。如果意图失败,回落到正确的网页

This bit of code figures out which store it was installed from, then tries Google Play and Amazon Appstore. If the intents fail, it falls back to the right web page

String installer = getPackageManager().getInstallerPackageName(getPackageName());
if ("com.amazon.venezia".equals(installer)) {

    try {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setData(Uri.parse("amzn://apps/android?p=com.monadpad...."));
        startActivity(intent);

    }
    catch (Exception e) {
        Intent browser = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.amazon.com..."));
        startActivity(browser);
    }


}
else if ("com.android.vending".equals(installer)) {
    try {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setData(Uri.parse("market://details?id=com.monadpad..."));
        startActivity(intent);
    }
    catch (Exception e) {
        Intent browser = new Intent(Intent.ACTION_VIEW,
                Uri.parse("https://play.google.com/store/apps/details?id=com.monadpad...."));
        startActivity(browser);
    }

}

这篇关于发送包的名称以任何市场的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆