Other methods
There are some other methods in the adjoe SDK which you might find helpful.
name
description
getVersion
Returns the internal version code of the adjoe SDK, for example 17.
getVersionName
Returns the version name of the adjoe SDK, for example 1.2.0.
hasAcceptedTOS
Returns true if the user has accepted the adjoe TOS and false otherwise.
hasAcceptedUsagePermission
Returns true if the user has granted access to the app usage statistics and the adjoe SDK was initialized accordingly, false otherwise. Note that this method will always return true on devices with an Android API level smaller than 21.

Payout via SDK

The following information on SDK-side reward handling is only relevant for your integration if you cannot use Server-to-Server Payout. Do not implement these functions if you already successfully followed the steps in the Payout section - it could trigger error messages and unexpected behaviour.
If you cannot handle the payout requests via an endpoint on your server, we can also handle the reward payouts inside the SDK itself.
To pay out the rewards that the user has collected from partner apps directly in the SDK, call
Java
Kotlin
1
try {
2
Adjoe.doPayout(context, new AdjoePayoutListener() {
3
4
@Override
5
public void onPayoutExecuted(int rewards) {
6
// successfully paid out 'rewards' rewards
7
}
8
9
@Override
10
public void onPayoutError(AdjoePayoutError adjoePayoutError) {
11
// an error occurred while paying out the rewards
12
13
// get information about why it failed
14
// 'reason' is one of
15
// - AdjoePayoutError.UNKNOWN
16
// - AdjoePayoutError.NOT_ENOUGH_COINS
17
// - AdjoePayoutError.TOS_NOT_ACCEPTED
18
int reason = adjoePayoutError.getReason();
19
20
// if available, get more information about the error
21
if (error.getException() != null) {
22
error.getException().printStackTrace();
23
}
24
}
25
});
26
} catch(AdjoeNotInitializedException e) {
27
// make sure to initialize the adjoe SDK first
28
}
Copied!
1
try {
2
Adjoe.doPayout(context, object: AdjoePayoutListener {
3
4
override fun onPayoutExecuted(coins: Int) {
5
// successfully paid out 'coins' coins
6
}
7
8
override fun onPayoutError(adjoePayoutError: AdjoePayoutError) {
9
// an error occurred while paying out the coins
10
11
// get information about why it failed
12
// 'reason' is one of
13
// - AdjoePayoutError.UNKNOWN
14
// - AdjoePayoutError.NOT_ENOUGH_COINS
15
// - AdjoePayoutError.TOS_NOT_ACCEPTED
16
val reason = adjoePayoutError.reason
17
18
// if available, get more information about the error
19
if (error.exception != null) {
20
error.exception.printStackTrace()
21
}
22
}
23
});
24
} catch(e: AdjoeNotInizializedException) {
25
// make sure to initialize the adjoe SDK first
26
}
Copied!
This method always pays out all rewards which the user has collected, i.e. the value of AdjoeRewardResponse.getAvailablePayoutCoins().
If the user has not accepted the adjoe Terms of Service yet, this operation will fail and reason will be equal to AdjoePayoutError.TOS_NOT_ACCEPTED. You might want to display the offerwall again so that the user can accept the adjoe Terms of Service. This operation will also fail with reason equal to AdjoePayoutError.UNKNOWN if the user is blocked by the adjoe services.

Adjoe Parameters

You can pass additional UA and placement parameters when you pay out the rewards:
Java
Kotlin
1
AdjoeParams adjoeParams = new AdjoeParams.Builder()
2
.setUaNetwork("network")
3
.setUaChannel("channel")
4
.setUaSubPublisherCleartext("SubPublisherCleartext")
5
.setUaSubPublisherEncrypted("SubPublisherEncrypted")
6
.setPlacement("placement")
7
.build();
8
Adjoe.doPayout(context, adjoeParams, listener)
Copied!
1
val adjoeParams = AdjoeParams.Builder()
2
.setUaNetwork("network")
3
.setUaChannel("channel")
4
.setUaSubPublisherCleartext("SubPublisherCleartext")
5
.setUaSubPublisherEncrypted("SubPublisherEncrypted")
6
.setPlacement("placement")
7
.build()
8
Adjoe.doPayout(context, adjoeParams, listener)
Copied!

Retrying the payout

Sometimes, it can happen that the latest rewards haven't been processed yet by the server when you pay out. In this case, the onPayoutError function would be invoked with reason equal to AdjoePayoutError.NOT_ENOUGH_COINS. To overcome this, you can implement a retry mechanism for the payout, for example with an exponential backoff.
Example:
Java
Kotlin
1
private static final long PAYOUT_RETRY_BASE = 2000;
2
private static final long PAYOUT_RETRY_MULTIPLIER = 2;
3
private static final int MAX_PAYOUT_RETRIES = 5;
4
private static final Handler ADJOE_PAYOUT_HANDLER = new Handler();
5
6
public void doAdjoePayout() {
7
doAdjoePayoutInternal(0);
8
}
9
10
private void doAdjoePayoutInternal(int times) {
11
if (times < 0 || times >= MAX_PAYOUT_RETRIES) {
12
// the payout has failed too often, which means that the user has no coins
13
// you should handle this case properly
14
return;
15
}
16
17
Adjoe.doPayout(context, new AdjoePayoutListener() {
18
19
@Override
20
public void onPayoutExecuted(int coins) {
21
// everything is fine, coins have been paid out
22
}
23
24
@Override
25
public void onPayoutError(AdjoePayoutError error) {
26
if (error.getReason() == AdjoePayoutError.NOT_ENOUGH_COINS) {
27
ADJOE_PAYOUT_HANDLER.postDelayed(new Runnable() {
28
29
@Override
30
public void run() {
31
doAdjoePayoutInternal(times + 1);
32
}
33
}, PAYOUT_RETRY_BASE * Math.pow(PAYOUT_RETRY_MULiTIPLiER, times));
34
}
35
}
36
});
37
}
Copied!
1
private val PAYOUT_RETRY_BASE:Long = 2000
2
private val PAYOUT_RETRY_MULTIPLIER:Long = 2
3
private val MAX_PAYOUT_RETRIES = 5
4
private val ADJOE_PAYOUT_HANDLER = Handler()
5
6
fun doAdjoePayout() {
7
doAdjoePayoutInternal(0)
8
}
9
10
private fun doAdjoePayoutInternal(times:Int) {
11
if (times < 0 || times >= MAX_PAYOUT_RETRIES)
12
{
13
// the payout has failed too often, which means that the user has no coins
14
// you should handle this case properly
15
return
16
}
17
Adjoe.doPayout(context, object:AdjoePayoutListener() {
18
fun onPayoutExecuted(coins:Int) {
19
// everything is fine, coins have been paid out
20
}
21
fun onPayoutError(error:AdjoePayoutError) {
22
if (error.getReason() === AdjoePayoutError.NOT_ENOUGH_COINS)
23
{
24
ADJOE_PAYOUT_HANDLER.postDelayed(object:Runnable {
25
public override fun run() {
26
doAdjoePayoutInternal(times + 1)
27
}
28
}, PAYOUT_RETRY_BASE * Math.pow(PAYOUT_RETRY_MULiTIPLiER, times))
29
}
30
}
31
})
32
}
Copied!

Further Context on Rewards

You can get information about the rewards that the user has collected as well as about how many rewards are available for payout and how many the user has already spent.
To do so call
Java
Kotlin
1
try {
2
Adjoe.requestRewards(context, new AdjoeRewardListener() {
3
4
@Override
5
public void onUserReceivesReward(AdjoeRewardResponse adjoeRewardResponse) {
6
// successfully requested the rewards
7
8
// get how many rewards the user has collected
9
int reward = adjoeRewardResponse.getReward();
10
11
// get how many rewards are available for payout
12
int availableForPayout = adjoeRewardResponse.getAvailablePayoutCoins();
13
14
// get how many rewards the user has already spent
15
int alreadySpentCoins = adjoeRewardResponse.getAlreadySpentCoins();
16
}
17
18
@Override
19
public void onUserReceivesRewardError(AdjoeRewardResponseError adjoeRewardResponseError) {
20
// an error occurred while requesting the rewards
21
22
// you can try to get additional information about the error for debugging
23
if (adjoeRewardResponseError.getException() != null) {
24
adjoeRewardResponseError.getException().printStackTrace();
25
}
26
}
27
});
28
} catch (AdjoeNotInitializedException e) {
29
// make sure to initialize the adjoe SDK first
30
}
Copied!
1
private val PAYOUT_RETRY_BASE:Long = 2000
2
private val PAYOUT_RETRY_MULTIPLIER:Long = 2
3
private val MAX_PAYOUT_RETRIES = 5
4
private val ADJOE_PAYOUT_HANDLER = Handler()
5
6
fun doAdjoePayout() {
7
doAdjoePayoutInternal(0)
8
}
9
10
private fun doAdjoePayoutInternal(times:Int) {
11
if (times < 0 || times >= MAX_PAYOUT_RETRIES)
12
{
13
// the payout has failed too often, which means that the user has no coins
14
// you should handle this case properly
15
return
16
}
17
Adjoe.doPayout(context, object:AdjoePayoutListener() {
18
fun onPayoutExecuted(coins:Int) {
19
// everything is fine, coins have been paid out
20
}
21
fun onPayoutError(error:AdjoePayoutError) {
22
if (error.getReason() === AdjoePayoutError.NOT_ENOUGH_COINS)
23
{
24
ADJOE_PAYOUT_HANDLER.postDelayed(object:Runnable {
25
public override fun run() {
26
doAdjoePayoutInternal(times + 1)
27
}
28
}, PAYOUT_RETRY_BASE * Math.pow(PAYOUT_RETRY_MULiTIPLiER, times))
29
}
30
}
31
})
32
}
Copied!
This operation will fail if the user has not accepted the adjoe Terms of Service or is blocked by the adjoe services.

UA Parameters

You can pass additional UA and placement parameters when you request the rewards:
Java
Kotlin
1
AdjoeParams adjoeParams = new AdjoeParams.Builder()
2
.setUaNetwork("network")
3
.setUaChannel("channel")
4
.setUaSubPublisherCleartext("SubPublisherCleartext")
5
.setUaSubPublisherEncrypted("SubPublisherEncrypted")
6
.setPlacement("placement")
7
.build();
8
Adjoe.requestRewards(context, adjoeParams, listener);
Copied!
1
val adjoeParams = AdjoeParams.Builder()
2
.setUaNetwork("network")
3
.setUaChannel("channel")
4
.setUaSubPublisherCleartext("SubPublisherCleartext")
5
.setUaSubPublisherEncrypted("SubPublisherEncrypted")
6
.setPlacement("placement")
7
.build()
8
Adjoe.requestRewards(context, adjoeParams, listener)
Copied!
Last modified 17d ago