如果我在Android市场上有一个免费版本的付费应用,如何在免费应用中放置一个按钮,以打开市场上的付费版本?
最好使用"market://details"而不是"market://search":
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=com.android.example"));
startActivity(intent);
接着它会直接打开应用程序的详细页面。在搜索中,它只显示单个搜索结果,用户必须再点击一次才能进入详细页面。
将此代码添加到按钮的 OnClickListener 的 onClick 方法中:
Intent marketLaunch = new Intent(Intent.ACTION_VIEW);
marketLaunch.setData(Uri.parse("market://search?q=uk.co.ashtonbrsc"));
startActivity(marketLaunch);
用一个能够找到你的应用程序的搜索词替换uk.co.ashtonbrsc
。