private static final long PAYOUT_RETRY_BASE = 2000;
private static final long PAYOUT_RETRY_MULTIPLIER = 2;
private static final int MAX_PAYOUT_RETRIES = 5;
private static final Handler ADJOE_PAYOUT_HANDLER = new Handler();
public void doAdjoePayout() {
doAdjoePayoutInternal(0);
private void doAdjoePayoutInternal(int times) {
if (times < 0 || times >= MAX_PAYOUT_RETRIES) {
// the payout has failed too often, which means that the user has no coins
// you should handle this case properly
Adjoe.doPayout(context, new AdjoePayoutListener() {
public void onPayoutExecuted(int coins) {
// everything is fine, coins have been paid out
public void onPayoutError(AdjoePayoutError error) {
if (error.getReason() == AdjoePayoutError.NOT_ENOUGH_COINS) {
ADJOE_PAYOUT_HANDLER.postDelayed(new Runnable() {
doAdjoePayoutInternal(times + 1);
}, PAYOUT_RETRY_BASE * Math.pow(PAYOUT_RETRY_MULiTIPLiER, times));