从另一个应用程序内部到市场的 Android 链接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3442366/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android Link to Market from inside another app
提问by Ian Vink
I am building many apps for Android and wish to have a menu button in the apps that basically opens a list of my other apps in the Android Market.
我正在为 Android 构建许多应用程序,并希望在应用程序中有一个菜单按钮,基本上可以打开我在 Android 市场中的其他应用程序的列表。
Is there a way to create an intent and have the Android market pop up with a search (of my company) in the market so users can buy other apps?
有没有办法创建一个意图并让 Android 市场在市场上搜索(我公司的),以便用户可以购买其他应用程序?
ian
安
回答by uwe
Even better to use "market://details" instead of "market://search":
最好使用“market://details”而不是“market://search”:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=com.android.example"));
startActivity(intent);
Then it opens directly the details page of the app. With search it shows a single search result and the user has to do an additional click to get to the detail page.
然后它直接打开应用程序的详细信息页面。通过搜索,它会显示单个搜索结果,用户必须额外单击才能进入详细信息页面。
回答by CommonsWare
Yes, there is a documented Intent
syntaxfor that (http://market.android.com/search?q=pub:<Developer Name>
or market://search?q=pub:<Developer Name>
).
是的,有一个文档化的Intent
语法(http://market.android.com/search?q=pub:<Developer Name>
或market://search?q=pub:<Developer Name>
)。
回答by Tapirboy
The intent action would be view, and uri the market url/uri.
意图操作是查看,uri 是市场 url/uri。
Like this:
像这样:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pub:<developer name>") ) );
回答by Kapil Jituri
Another way is to launch a URL Intent
with your application's package name in it.
User will get popup with list of installed Browsers+ Play Storeapp in which he can view your target app.
另一种方法是URL Intent
使用您的应用程序的包名称启动一个。用户将看到已安装浏览器+ Play 商店应用程序列表的弹出窗口,他可以在其中查看您的目标应用程序。
String appPackageName = "com.example.android";
String url = "https://play.google.com/store/apps/details?id=" + appPackageName;
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
Above code is tested and works as expected on Play Store version 4.1.6
以上代码已在 Play 商店版本 4.1.6 上测试并按预期工作
回答by Alexey Vassiliev
On my real devices Sony Xperia Pro and PocketBook tablet, even when you put a link to play web store e.g. https://play.google.com/store/apps/details?id=com.estrongs.android.popIt will ask if you want to open it in the default browser or in the Play market. If you select Play market - application is shown as expected. Did not test it with intent, tested with Autolink from TextView.
在我的真实设备 Sony Xperia Pro 和 PocketBook 平板电脑上,即使你放了一个链接来玩网上商店,例如https://play.google.com/store/apps/details?id=com.estrongs.android.pop它会问如果您想在默认浏览器或 Play 市场中打开它。如果您选择 Play market - 应用程序将按预期显示。没有故意测试它,用 TextView 的自动链接测试。
回答by The Java Guy
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.adfree:
final String appPackageName = "com.zooohooo.noads"; // Can also use getPackageName(), as below
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
return true;
case R.id.rate:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName())));
return true;
}
return super.onOptionsItemSelected(item);
}