Step-by-Step Integration Guide
1. Add user consent
Always obtain user consent before starting bandwidth sharing. The SDK provides a built-in consent dialog:
Orbitly.showConsentDialog(activity, new ConsentCallback() {
@Override
public void onConsentGranted() {
Orbitly.start();
}
@Override
public void onConsentDenied() {
// User declined — do not start sharing
}
});
Alternatively, build your own UI and call Orbitly.setConsentGiven(true) when the user agrees.
2. Start sharing at the right time
Best practices for when to start the SDK:
- After user login and consent
- When the user navigates to a "rewards" or "earnings" section
- On app startup (if consent was previously given)
if (Orbitly.hasConsent()) {
Orbitly.start();
}
3. Show earnings to users
Orbitly.getEarnings(new EarningsCallback() {
@Override
public void onResult(EarningsInfo info) {
textView.setText("Earned: $" + info.getTotalEarnings());
}
});
4. Handle lifecycle
The SDK manages its own lifecycle via a foreground service. However, you should stop it when the user logs out:
public void onUserLogout() {
Orbitly.stop();
Orbitly.clearSession();
}
5. ProGuard / R8 rules
If you use code shrinking, add the following to your proguard-rules.pro:
-keep class com.orbitly.sdk.** { *; }