[英]In BillingClient setup .setListener(this) references my calling activity instead of a PurchasesUpdatedListener
The docs show the following for setting up a Billingclient.文档显示了用于设置 Billingclient 的以下内容。
private BillingClient billingClient;
...
billingClient = BillingClient.newBuilder(activity).setListener(this).build();
In .setListener(this), the 'this' part is supposed to reference a PurchasesUpdatedListener, even though you don't explicitly create one to put in these parenthesis.在 .setListener(this) 中,'this' 部分应该引用一个 PurchasesUpdatedListener,即使您没有明确地创建一个放在这些括号中。 Apparently just using 'this' is supposed to be enough.
显然只使用'this'就足够了。 In the docs and all the examples I've seen, a PurchasesUpdatedListener is never created to put here, it just uses 'this', apparently self-referencing the billingclient being created.
在文档和我见过的所有示例中,从来没有创建一个 PurchasesUpdatedListener 来放在这里,它只是使用“this”,显然是自引用正在创建的 billingclient。 This hasn't worked for me though, and I keep getting:
不过,这对我不起作用,而且我不断收到:
Should I use something else for the (activity) part than (getApplicationContext())?我应该为(活动)部分使用其他东西而不是(getApplicationContext())吗? I've tried (this) and various other things here as just the word 'activity' isn't recognized.
我在这里尝试过(这个)和其他各种事情,因为只有“活动”这个词不被识别。
Instead setListener(this)
put setListener(new PurchasesUpdatedListener(){... })
and implement the required methods (usually AndroidStudio does it automatically)相反
setListener(this)
把setListener(new PurchasesUpdatedListener(){... })
并实现所需的方法(通常 AndroidStudio 会自动执行)
Or或者
add .. implements PurchasesUpdatedListener
at the end of your MainActivity declaration在 MainActivity 声明的末尾添加 ..
implements PurchasesUpdatedListener
the same thing as you can do on many listeners, for example the well known OnClickListener与您可以对许多侦听器执行的操作相同,例如众所周知的 OnClickListener
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.