在BillingClient设置中。setListener(this)引用我的呼叫活动,而不是PurchasesUpdatedListener

问题描述 投票:0回答:1

文档显示了以下用于设置Billingclient的信息。

private BillingClient billingClient;
...
billingClient = BillingClient.newBuilder(activity).setListener(this).build();  

在.setListener(this)中,“ this”部分应该引用PurchasesUpdatedListener,即使您没有显式创建要放在这些括号中的内容也是如此。显然,仅使用“ this”就足够了。在我看到的文档和所有示例中,从来没有创建PurchasesUpdatedListener放在这里,它只使用“ this”,显然是自引用正在创建的billingclient。不过,这对我没有用,并且我不断得到:

enter image description here

我应该为(活动)部分使用(getApplicationContext())以外的其他东西吗?我已经尝试过(this)和其他各种操作,因为无法识别“活动”一词。

in-app-purchase in-app-billing billing billingclient
1个回答
0
投票

代替setListener(this)放置setListener(new PurchasesUpdatedListener(){... })并实现所需的方法(通常AndroidStudio会自动执行)

在MainActivity声明末尾添加.. implements PurchasesUpdatedListener

与您可以在许多侦听器上进行的相同操作,例如众所周知的OnClickListener

© www.soinside.com 2019 - 2024. All rights reserved.