本文翻译自:How to open the Google Play Store directly from my Android application?

I have open the Google Play store using the following code 我已使用以下代码打开Goog​​le Play商店

Intent i = new Intent(android.content.Intent.ACTION_VIEW);
i.setData(Uri.parse("https://play.google.com/store/apps/details?id=my packagename "));
startActivity(i);.

But it shows me a Complete Action View as to select the option (browser/play store). 但它显示了一个完整的动作视图,以选择选项(浏览器/播放商店)。 I need to open the application in Play Store directly. 我需要直接在Play商店中打开应用程序。


#1楼

参考:https://stackoom.com/question/nJUW/如何直接从我的Android应用程序打开Goog-le-Play商店


#2楼

You can do this using the market:// prefix . 您可以使用market://前缀执行此操作。

final String appPackageName = getPackageName(); // getPackageName() from Context or Activity object
try {startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
}

We use a try/catch block here because an Exception will be thrown if the Play Store is not installed on the target device. 我们使用try/catch这里块,因为Exception将被抛出,如果Play商店未在目标设备上安装。

NOTE : any app can register as capable of handling the market://details?id=<appId> Uri, if you want to specifically target Google Play check the Berťák answer 注意 :任何应用都可以注册为能够处理market://details?id=<appId> Uri,如果您想专门针对Google Play检查Berťák答案


#3楼

使用市场://

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + my_packagename));

#4楼

You can do: 你可以做:

final Uri marketUri = Uri.parse("market://details?id=" + packageName);
startActivity(new Intent(Intent.ACTION_VIEW, marketUri));

get Reference here : 在这里得到参考:

You can also try the approach described in the accepted answer of this question: Cannot determine whether Google play store is installed or not on Android device 您还可以尝试此问题的接受答案中描述的方法: 无法确定Android设备上是否安装了Google Play商店


#5楼

try this 试试这个

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

#6楼

You can check if the Google Play Store app is installed and, if this is the case, you can use the "market://" protocol. 您可以检查是否已安装Google Play商店应用,如果是这种情况,您可以使用“market://”协议。

final String my_package_name = "........."  // <- HERE YOUR PACKAGE NAME!!
String url = "";try {//Check whether Google Play store is installed or not:this.getPackageManager().getPackageInfo("com.android.vending", 0);url = "market://details?id=" + my_package_name;
} catch ( final Exception e ) {url = "https://play.google.com/store/apps/details?id=" + my_package_name;
}//Open the app page in Google Play store:
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
startActivity(intent);

如何直接从我的Android应用程序打开Goog​​le Play商店?相关推荐

  1. 创建一个简单的Android应用程序

    创建第一个Android应用程序 打开Android Studio,选择新创建一个Project: 点击创建时Android Studio会给我们提供一些基础模板,我们可以根据需要选择模板对应项目创建 ...

  2. Xposed: 勾住(Hook) Android应用程序对象的方法,实现AOP

    Xposed Xposed能够勾住(Hook) Android应用程序对象的方法,实现AOP,一个简单的例子: public class WebViewHook implements IXposedH ...

  3. Android应用程序消息处理机制(Looper、Handler)分析(2)

    我们再回到NativeMessageQueue的构造函数中,看看JNI层的Looper对象的创建过程,即看看它的构造函数是如何实现的,这个Looper类实现在frameworks/base/libs/ ...

  4. 电子界卡组构建2019_2018–2019年构建现代Android应用程序的路线图

    电子界卡组构建2019 Kriptofolio应用程序系列-简介 (Kriptofolio app series - Introduction) Welcome to this series of b ...

  5. 在 Android 应用程序中使用 SQLite 数据库以及怎么用

    part one : android SQLite 简单介绍 SQLite 介绍 SQLite 一个非常流行的嵌入式数据库.它支持 SQL 语言,而且仅仅利用非常少的内存就有非常好的性能.此外它还是开 ...

  6. Android 应用程序窗体显示状态操作(requestWindowFeature()的应用)

    转自:http://www.cnblogs.com/salam/archive/2010/11/30/1892143.html 我们在开发程序是经常会需要软件全屏显示.自定义标题(使用按钮等控件)和其 ...

  7. php安卓传输图片到mysql_php – Android应用程序将图像发送到MySQL

    我有一个 Android应用程序,它将图像发送到我的数据库; public class NewProductActivity extends Activity { // Progress Dialog ...

  8. win10 android 登录,Microsoft现在允许您在Win10中运行Android应用程序

    8月7日消息:昨天,微软宣布了一项新功能,允许Win10用户在Windows 10中直接启动Android应用程序. 只有在选择三星Galaxy设备并允许Android将应用程序流到Windows 1 ...

  9. Android应用程序的调试

    adb   devices 这条命令用于列出当前adb服务器所能检测到的所有模拟器和手机.这也是快速获取模拟器或者手机TCP/IP通信端口的一个方法.如果当前系统中只连接了一个模拟器或手机,那么其他所 ...

最新文章

  1. tongweb安装部署_Linux系统东方通部署iserver说明
  2. Java中的注解--annotation
  3. 问题 1047: [编程入门]报数问题
  4. MongoDB可视化界面工具Studio3T的安装 - 讲解篇
  5. ISSN和EAN原理及转换【转载】
  6. aarch64(ARMv8)交叉编译环境下载
  7. 高通骁龙888来了!新命名就是为了中国,小米11将全球首发
  8. 解决java.io.IOException: HTTPS hostname wrong: should be
  9. 二叉排序树的插入 java_leetcode刷题笔记-701. 二叉搜索树中的插入操作(java实现)...
  10. 设置GRUB菜单密码
  11. 世界上最简单的会计书-笔记
  12. 使用xml配置文件实现HSF框架和EDAS注册服务器的发布-订阅模式
  13. u盘需要计算机管理权限,u易u盘需要管理员权限的文件怎么删除
  14. 深入浅出Meta Learning - 让机器学会如何去学习
  15. mysql中查看密码有效期_Mysql5.7.9密码已过有效期的处理过程
  16. 实现Excel单元格中的下拉选项和数据有效性
  17. 计算机软件分类系统软件和,计算机化系统软件分类和验证
  18. NFV与SDN的区别与联系
  19. 数字电路模2运算原理,及模2的加减乘除详解
  20. Java Web学习笔记

热门文章

  1. 循环冗余检验 CRC
  2. 【网络安全】网站为什么需要安装SSL安全证书?
  3. 操作系统知识:程序计数器(pc)、指令寄存器(IR)、通用寄存器(GR)、状态寄存器(SR)、程序状态字PSW
  4. 捷径系列:Notification
  5. 如何防止人工智能毁灭人类
  6. FreeSWITCH对接SIP中继 语音外呼电话机器人 配置技术指导 www.ruikesoft.com
  7. 苹果Safari浏览器Safari Technology Preview
  8. C语言函数大全--g开头的函数(下)
  9. java图片中各颜色占比_计算图片中某种颜色所占的面积比例 - Photoshop 方法
  10. 彻底卸载网易UU网游加速器的方法