繁体   English   中英

如何使用 package 名称打开 Google Play? 还是带有 Url 的 Chrome?

[英]How can I open Google Play with package name? or Chrome with Url?

如果我的应用尚未安装,我想在 Google Play 上展示它。

所以,我尝试了这个:

        try {
            context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$packageName")))
        } catch (anfe : ActivityNotFoundException) {
            try {
                context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=$packageName")))
            } catch (anfe : ActivityNotFoundException) {
                context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://www.naver.com")))
            }
        }

这段代码在我的旧设备上运行良好。 但现在我正在尝试使用三星 Galaxy20+。 它显示了这个错误。

 To View this content, install and set up a web browsing app.

是设备问题没有设置默认浏览器吗? 如果是,有什么方法可以用 Chrome 打开 url? 但是我需要一个浏览器来打开市场吗???

在此处输入图像描述

来自https://developer.android.com/distribute/marketing-tools/linking-to-google-play#android-app

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(
        "https://play.google.com/store/apps/details?id=com.example.android"));
intent.setPackage("com.android.vending");
startActivity(intent);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM