Refactoring

This commit is contained in:
M66B 2022-12-11 16:27:28 +01:00
parent cc5dc26844
commit 84cfc8472b
1 changed files with 14 additions and 8 deletions

View File

@ -115,6 +115,20 @@ public class ActivityBilling extends ActivityBase implements
.setListener(this)
.build();
billingClient.startConnection(this);
getLifecycle().addObserver(new LifecycleObserver() {
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
public void onDestroyed() {
getLifecycle().removeObserver(this);
if (billingClient != null)
try {
Log.i("IAB end");
billingClient.endConnection();
billingClient = null;
} catch (Throwable ex) {
Log.e(ex);
}
}
});
} catch (Throwable ex) {
Log.e(ex);
/*
@ -180,14 +194,6 @@ public class ActivityBilling extends ActivityBase implements
}
}
@Override
protected void onDestroy() {
if (billingClient != null)
billingClient.endConnection();
super.onDestroy();
}
@NonNull
static String getSkuPro(Context context) {
if (isTesting(context))