This repository has been archived by the owner on Apr 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Configuration
mikemee edited this page Sep 15, 2015
·
8 revisions
Before utilizing library capabilities it must be configured.
The best place for it by far is Application.onCreate()
callback.
BillingListener
- is you main entry point for all incoming billing events. It's strongly recommended to
save all intermediate results to some kind of persistent storage (DataBase, ContentProvider, SharedPreferences etc.).
You can implement BillingListener
from scratch or extend pre-defined DefaultBillingListener
which will do following things:
- Attempt to consume any
Consumable
items purchased by user. - Attempt to fully load user inventory, if it was loaded only partially.
final BillingListener myListener = new SimpleBillingListener() {
// Handle desired callbacks.
@Override
public void onConsume(@NonNull final ConsumeResponse consumeResponse) {
super.onConsume(consumeResponse);
if (consumeResponse.isSuccessful()) {
MyPresistentStorage.awardCoins();
}
}
}
There are several options available in Configuration
object, check JavaDoc for more details.
final Configuration configuration = new Configuration.Builder()
// Billing providers will be prioritized in the same order you added them
.addBillingProvider(provider1)
.addBillingProvider(provider2)
.setBillingListener(myListener)
.build();
public class MyApplication extends Application {
@Override
public void onCreate() {
OPFIab.init(this, configuration);
}
}
Now library should be properly initialized, all that's left is just Pick Provider.