IAB standalone

This commit is contained in:
M66B 2021-05-23 15:21:12 +02:00
parent c008ca8ed0
commit dc123ecded
1 changed files with 15 additions and 8 deletions

View File

@ -68,6 +68,7 @@ import java.util.Date;
import java.util.List;
public class ActivityBilling extends ActivityBase implements PurchasesUpdatedListener, FragmentManager.OnBackStackChangedListener {
private boolean standalone = false;
private BillingClient billingClient = null;
private List<IBillingListener> listeners = new ArrayList<>();
@ -88,6 +89,8 @@ public class ActivityBilling extends ActivityBase implements PurchasesUpdatedLis
protected void onCreate(Bundle savedInstanceState, boolean standalone) {
super.onCreate(savedInstanceState);
this.standalone = standalone;
if (standalone) {
setContentView(R.layout.activity_billing);
@ -120,12 +123,14 @@ public class ActivityBilling extends ActivityBase implements PurchasesUpdatedLis
protected void onResume() {
super.onResume();
if (standalone) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
IntentFilter iff = new IntentFilter();
iff.addAction(ACTION_PURCHASE);
iff.addAction(ACTION_PURCHASE_CONSUME);
iff.addAction(ACTION_PURCHASE_ERROR);
lbm.registerReceiver(receiver, iff);
}
if (billingClient != null && billingClient.isReady())
queryPurchases();
@ -135,9 +140,11 @@ public class ActivityBilling extends ActivityBase implements PurchasesUpdatedLis
protected void onPause() {
super.onPause();
if (standalone) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
lbm.unregisterReceiver(receiver);
}
}
@Override
protected void onDestroy() {