如何在我的android应用程序中插入促销代码以购买商品?

Sat*_*tli 0 android promotion-code google-play

我已经在我的应用程序中实现了InApp购买,并且可以正常工作。现在想使用促销代码自由获取商品。

在文档中说:您的应用程序应允许用户在应用程序内部兑换促销代码。如果您的应用程序支持应用程序内购买工作流程(如发出应用程序内结算请求中所述),则您的应用程序将自动支持促销代码在应用程序内的兑换。当您启动应用内购买用户界面时,用户可以选择使用促销代码付款。 https://developer.android.com/google/play/billing/billing_promotions.html

But in my application there is not any option to select for promo code. There is only buy option. How can user insert promo code inside app?

这些图片来自PlayStore应用。有Redeem对话框的模样peyment对话框。可以按照本文和以下图片中所述从play store应用程序中打开它。我可以按照以下流程插入我的促销代码,它可以正常工作。 http://www.greenbot.com/article/3043048/android/how-to-redeem-a-google-play-store-promo-code.html
在此处输入图片说明 兑换对话框

Web*_*eis 5

在这种SO中,您找到的解决方案

修改代码

String code = "request code with dialog"
try {
    String url = "https://play.google.com/redeem?code=" + URLEncoder.encode(code, "UTF-8");
    context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
} catch (android.content.ActivityNotFoundException e) {
  // Play Store app is not installed
}
Run Code Online (Sandbox Code Playgroud)