open link of google play store in mobile version android(在手机版android中打开google play store的链接)
问题描述
我的最新应用中有其他应用的链接,我以这种方式打开它们.
I have link of my other apps in my latest app, and I open them in that way.
Uri uri = Uri.parse("url");
Intent intent = new Intent (Intent.ACTION_VIEW, uri);
startActivity(intent);
此代码将打开 google play store 的浏览器版本.
this codes opens the browser version of google play store.
当我尝试从我的手机打开时,手机会提示我是要使用浏览器还是 google play,如果我选择第二个,它会打开手机版的 google play store.
When trying to open from my phone, the phone prompts if I want to use a browser or google play and if I choose the second one it opens the mobile version of google play store.
你能告诉我这怎么会立即发生?我的意思是不问我,直接打开手机版的google play,我直接从手机打开看到的那个.
Can you tell me how can this happen at once? I mean not ask me but directly open the mobile version of google play, the one that I see while open it directly from phone.
推荐答案
你需要使用指定的 market
协议:
You'll want to use the specified market
protocol:
final String appPackageName = "com.example"; // Can also use getPackageName(), as below
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
请记住,这将在任何未安装 Market 的设备(例如模拟器)上崩溃.因此,我建议如下:
Keep in mind, this will crash on any device that does not have the Market installed (the emulator, for example). Hence, I would suggest something like:
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("http://play.google.com/store/apps/details?id=" + appPackageName)));
}
使用 getPackageName()
时 来自 Context
或其子类以保持一致性(感谢 @cprcrack!).您可以在此处找到有关市场意图的更多信息:链接强>.
While using getPackageName()
from Context
or subclass thereof for consistency (thanks @cprcrack!). You can find more on Market Intents here: link.
这篇关于在手机版android中打开google play store的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在手机版android中打开google play store的链接


基础教程推荐
- NSString intValue 不能用于检索电话号码 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01