use of com.android.billingclient.api.BillingResult in project PhoneProfiles by henrichg.
the class BillingManager method startServiceConnectionIfNeeded.
private void startServiceConnectionIfNeeded(final Runnable executeOnSuccess) {
// PPApplication.logE(TAG, "startServiceConnectionIfNeeded");
if (mBillingClient.isReady()) {
if (executeOnSuccess != null) {
executeOnSuccess.run();
}
} else {
DonationFragment fragment = getFragment();
if (fragment != null)
fragment.setWaitScreen(true);
mBillingClient.startConnection(new BillingClientStateListener() {
@Override
public void onBillingSetupFinished(@NonNull BillingResult billingResult) {
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
if (executeOnSuccess == null) {
if (getFragment() != null)
getFragment().updateGUIAfterBillingConnected();
}
if (executeOnSuccess != null) {
executeOnSuccess.run();
}
}
/*else {
Log.w(TAG, "onBillingSetupFinished() error code: " + billingResponse);
}*/
}
@Override
public void onBillingServiceDisconnected() {
// Log.w(TAG, "onBillingServiceDisconnected()");
}
});
}
}
use of com.android.billingclient.api.BillingResult in project PhoneProfiles by henrichg.
the class BillingManager method querySkuDetailsAsync.
public void querySkuDetailsAsync(@BillingClient.SkuType final String itemType, final List<String> skuList, final SkuDetailsResponseListener listener) {
// Specify a runnable to start when connection to Billing client is established
Runnable executeOnConnectedService = new Runnable() {
@Override
public void run() {
SkuDetailsParams skuDetailsParams = SkuDetailsParams.newBuilder().setSkusList(skuList).setType(itemType).build();
mBillingClient.querySkuDetailsAsync(skuDetailsParams, new SkuDetailsResponseListener() {
@Override
public void onSkuDetailsResponse(@NonNull BillingResult billingResult, List<SkuDetails> skuDetailsList) {
listener.onSkuDetailsResponse(billingResult, skuDetailsList);
}
});
}
};
// If Billing client was disconnected, we retry 1 time and if success, execute the query
startServiceConnectionIfNeeded(executeOnConnectedService);
}
use of com.android.billingclient.api.BillingResult in project apcupsd-monitor by norkator.
the class MainMenu method initInAppBilling.
// ---------------------------------------------------------------------------------------------
/* In app billing features */
// Initialize in app billing feature
private void initInAppBilling() {
// In app billing
mBillingClient = BillingClient.newBuilder(this).enablePendingPurchases().setListener(this).build();
mBillingClient.startConnection(new BillingClientStateListener() {
@Override
public void onBillingSetupFinished(BillingResult billingResult) {
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
// The billing client is ready. You can query purchases here.
}
}
@Override
public void onBillingServiceDisconnected() {
// Try to restart the connection on the next request to
// Google Play by calling the startConnection() method.
}
});
}
Aggregations