I'm trying to write a Java for Android app using In-App Billing. I'm using this link as a guide. I've added the code they prescribe under Initialize a Billing Client, but I'm getting a message that the onPurchasesUpdated method does not override the method from its superclass. I suspect that I'm missing an implements, but which one? Or is that not the problem? Here's my code:
package com.knitcards.myapplication;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import androidx.appcompat.app.AppCompatActivity;
public class ShopActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shop);
}
private PurchasesUpdatedListener purchasesUpdatedListener = new PurchasesUpdatedListener() {
@Override
void onPurchasesUpdated(BillingResult billingResult, List<Purchase> purchases) {
}
};
}
implement like this:-
public class ShopActivity extends AppCompatActivity implements PurchasesUpdatedListener{
.
.
.
@Override
public void onPurchasesUpdated(@NonNull BillingResult billingResult, @Nullable List<Purchase> purchases) {
.
.
}
Or you can do like this. This is the recommended way by Google. Also attached is the Google Sample project