Android Reward Collection Agent
Android Reward Collection Agent
Goal
Build an Android AI UI navigator that can complete routine, allowed app tasks such as:
- Open selected Android apps or games.
- Claim daily login rewards.
- Claim new event login rewards when they appear.
- Click a configured button once every 24 hours, like the daily action in Pi Network or Bee Network.
- Record each run in a dashboard with status, screenshots, timestamps, and the next scheduled run time.
This plan intentionally avoids bypassing anti-cheat, captchas, account protections, purchases, rate limits, or anything that violates app rules. The agent should behave like a user following the visible UI.
Recommended architecture
1. Controller layer
Use a small backend service as the scheduler and brain.
Recommended stack:
- Python backend, FastAPI.
- SQLite first, Postgres later if needed.
- APScheduler or Celery beat for scheduled 24 hour runs.
- Playwright only for the web dashboard, not for Android control.
- Android control through an automation adapter.
The controller stores:
- Apps to automate.
- Reward tasks per app.
- Last successful claim time.
- Next allowed run time.
- Screenshots before and after each run.
- Step logs and failures.
- Human-readable status for the dashboard.
2. Android automation adapter
Support both real Android phones and emulators with the same high-level task interface.
Option A, real phone
Use either:
- Android Accessibility Service inside a companion app, best for reliable tapping, text detection from UI hierarchy, and long-running phone automation.
- ADB from a trusted PC/server, simpler to prototype but less seamless for an everyday phone.
For the real phone path, I recommend starting with ADB for prototyping, then moving stable flows into an Accessibility Service if you want the agent to run directly on-device.
Option B, emulator
Use:
- Appium + UiAutomator2 for structured element lookup.
- ADB fallback for screenshots, taps, swipes, app launch, and OCR-based fallback.
The emulator is best for always-on scheduled collection because it can run on a PC or cloud machine without interrupting your phone.
3. Agent execution model
Do not let the AI blindly tap the screen. Use a constrained state machine with AI only as a fallback interpreter.
Each app gets a task recipe like:
For games with daily rewards:
4. UI perception strategy
Use a three-level recognition system, from most reliable to least reliable.
Level 1, Android UI hierarchy
Read visible UI elements through Appium or Accessibility APIs:
- Text labels.
- Content descriptions.
- Button bounds.
- Package/activity state.
- Clickable elements.
Use this whenever possible because it is stable and avoids relying on screenshots.
Level 2, template and OCR fallback
When the app or game renders custom UI that does not expose useful accessibility labels:
- Take a screenshot.
- Run OCR to find visible text like “Claim,” “Daily,” “Collect,” “Start,” “Mine,” “24h,” “Reward,” “Event.”
- Use image templates for stable icons/buttons if needed.
- Tap the center of the matched region.
Level 3, AI fallback with guardrails
Use an LMM only when the deterministic rules cannot identify the current screen.
The AI should return a structured action only, for example:
Guardrails:
- Only allow actions from an approved list: tap, swipe, back, wait, screenshot, launch_app.
- Never allow purchase, captcha solving, password entry, changing account settings, or sending messages.
- Stop and ask for manual review if confidence is low or if a sensitive screen appears.
Dashboard design
Dashboard pages
Overview
- App name.
- Last run status.
- Last successful claim time.
- Next scheduled run.
- Device/emulator status.
Task history
- Each run with timestamp.
- Success, failed, skipped, or needs review.
- Step-by-step log.
- Before and after screenshots.
App configuration
- Package name.
- Schedule interval.
- Claim keywords.
- Event reward keywords.
- Success condition.
- Retry count.
Manual review
- Shows screenshot when automation is unsure.
- Lets you approve a suggested tap or mark the task complete.
Run statuses
Use these statuses:
success: reward or 24 hour button was claimed.already_claimed: the app says the reward is not available yet.skipped: the 24 hour timer has not elapsed.failed: app could not be opened, screen did not load, or success could not be verified.needs_review: agent found an unknown popup, captcha, login screen, purchase screen, or low confidence action.
Scheduler logic
For every task:
- Check
next_run_at. - If current time is earlier, skip.
- Start device session.
- Launch target app.
- Execute the task recipe.
- Verify success.
- Save screenshots and logs.
- Set next run time.
For 24 hour button apps:
- Use the last success time plus 24 hours as the default next run.
- If the app shows a countdown, parse it and update the next run time from the countdown.
- Add a small safety buffer, for example 5 to 15 minutes, to avoid tapping too early.
Failure handling
The agent should retry only safe actions.
Recommended retry behavior:
- App launch: retry 2 times.
- Network/loading wait: wait up to a configured timeout.
- Popup close: try known close buttons, then screenshot review.
- Claim button not found: check if already claimed, then mark
already_claimedorneeds_review. - Login required: stop, mark
needs_review. - Captcha or anti-bot challenge: stop, mark
needs_review. - Purchase/payment screen: stop, mark
needs_review.
Data model
Tables:
devices
idnametype, real_phone or emulatoradb_serialstatuslast_seen_at
apps
iddisplay_namepackage_nameenableddevice_id
tasks
idapp_idtask_type, daily_reward, event_reward, 24h_buttonschedule_typeinterval_hoursnext_run_atsuccess_conditionrecipe_json
runs
idtask_idstarted_atfinished_atstatussummarybefore_screenshot_pathafter_screenshot_pathnext_run_at
run_steps
idrun_idstep_namestatusmessagescreenshot_pathcreated_at
Implementation phases
Phase 1, prototype on emulator
Build a proof of concept with one app first.
Deliverables:
- FastAPI backend.
- SQLite database.
- Appium or ADB connection to emulator.
- Launch app.
- Take screenshots.
- Tap configured button by text, content description, OCR, or fixed fallback coordinate.
- Dashboard showing run history.
Phase 2, add task recipes
Add reusable recipes:
- Daily login reward claim.
- Event login reward claim.
- 24 hour button click.
- Popup closing.
- Success verification.
Phase 3, add real phone support
Add a device adapter abstraction:
Implement adapters for:
AdbDeviceAppiumDevice- later,
AccessibilityDevice
Phase 4, improve reliability
Add:
- Per-app screen state detection.
- OCR fallback.
- Template matching fallback.
- Manual review queue.
- Better countdown parsing.
- Notification on failure.
Phase 5, production hardening
Add:
- Encrypted secrets.
- Device health checks.
- Run cooldowns.
- Per-app rate limits.
- Screenshot retention policy.
- Exportable logs.
- Optional remote dashboard auth.
Output contract
Each completed run should produce a dashboard entry with:
What not to automate
The agent should stop and require manual review for:
- Captchas.
- Password or seed phrase prompts.
- Purchases or payment screens.
- Anti-cheat warnings.
- Account recovery screens.
- Anything that asks for irreversible confirmation.
Recommended first build target
Start with an emulator and one 24 hour button app, then add a game daily reward flow after the dashboard and scheduler are stable. This reduces risk because the 24 hour button task is simpler than event reward navigation.
Comments