Overview
PhoneClaw’s automation capabilities are powered by Android’s Accessibility Service, which provides programmatic access to UI elements across all apps on the device. This enables PhoneClaw to read screen content, find elements, and simulate user interactions.What is an Accessibility Service?
Android Accessibility Services were designed to help users with disabilities interact with their devices. PhoneClaw leverages these same APIs for automation:- Screen Reading: Access all text and UI elements currently visible
- UI Interaction: Click, type, scroll, and navigate programmatically
- Global Access: Works across all apps (with permission)
- Event Monitoring: Receive notifications when UI changes occur
Service Architecture
Service Lifecycle
FromMyAccessibilityService.kt:45-63:
The service maintains a singleton
instance that can be accessed from anywhere in the app. This allows ClawScript to trigger accessibility actions from JavaScript.Core Capabilities
1. Simulating Clicks
PhoneClaw can click at specific screen coordinates using gestures:2. Finding UI Elements
Accessibility Services can traverse the entire UI hierarchy:3. Text Detection
Check if specific text appears on screen:4. Text Input
Type into editable fields:5. Scrolling & Swiping
Advanced Features
Element Finding by View ID
Target specific UI elements using Android resource IDs:Extracting All Screen Text
App-Specific Automation
PhoneClaw includes specialized functions for popular apps:TikTok Automation
TikTok Automation
Instagram Automation
Instagram Automation
Permissions & Setup
1. Declare Service in AndroidManifest.xml
2. Configure Service Capabilities
res/xml/accessibility_service_config.xml
3. Check Permission Status
Best Practices
Performance Tips:
- Always check if
rootInActiveWindowis null before traversing - Recycle AccessibilityNodeInfo objects after use to prevent memory leaks
- Use specific targeting (View IDs, content descriptions) instead of full tree traversal
- Add delays between rapid UI interactions
Troubleshooting
Service Not Connected
Element Not Found
Click Not Working
If semantic clicks fail, fall back to coordinate-based clicks:Next Steps
Vision Targeting
Combine accessibility with vision AI
ClawScript
JavaScript automation API reference