gho*_*der 88 android google-play
我在我最新的应用程序中有我的其他应用程序的链接,我以这种方式打开它们.
Uri uri = Uri.parse("url");
Intent intent = new Intent (Intent.ACTION_VIEW, uri);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
此代码会打开Google Play商店的浏览器版本.
当我尝试从手机打开时,手机会提示我是否要使用浏览器或谷歌播放,如果我选择第二个,则会打开谷歌播放商店的移动版本.
你能告诉我这怎么可能立刻发生?我的意思是不要问我,而是直接打开谷歌播放的移动版本,我看到的那个直接从手机打开它.
Eri*_*ric 265
您将要使用指定的market协议:
final String appPackageName = "com.example"; // Can also use getPackageName(), as below
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
Run Code Online (Sandbox Code Playgroud)
请记住,这将在没有安装市场的任何设备(例如,模拟器)上崩溃.因此,我会建议:
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)));
}
Run Code Online (Sandbox Code Playgroud)
使用getPackageName()from Context或子类来保持一致性(感谢@cprcrack!).您可以在此处找到有关市场意图的更多信息:链接.
下面的代码可以帮助您在移动版中显示谷歌疮的应用程序链接.
对于应用程序链接
Uri uri = Uri.parse("market://details?id=" + mContext.getPackageName());
Intent myAppLinkToMarket = new Intent(Intent.ACTION_VIEW, uri);
try {
startActivity(myAppLinkToMarket);
} catch (ActivityNotFoundException e) {
//the device hasn't installed Google Play
Toast.makeText(Setting.this, "You don't have Google Play installed", Toast.LENGTH_LONG).show();
}
Run Code Online (Sandbox Code Playgroud)
对于开发者链接:
Uri uri = Uri.parse("market://search?q=pub:" + YourDeveloperName);
Intent myAppLinkToMarket = new Intent(Intent.ACTION_VIEW, uri);
try {
startActivity(myAppLinkToMarket);
} catch (ActivityNotFoundException e) {
//the device hasn't installed Google Play
Toast.makeText(Settings.this, "You don't have Google Play installed", Toast.LENGTH_LONG).show();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
121699 次 |
| 最近记录: |