Skip to main content
This example demonstrates a straightforward way to use the mobile-use SDK without builders or advanced configuration. It performs a real-world automation task.
This example is available on GitHub: simple_photo_organizer.py

What This Example Does

1

Opens the photo gallery

Navigates to the Photos/Gallery app
2

Finds photos from a specific date

Searches for photos taken yesterday
3

Creates an album

Creates a new album with a date-based name
4

Moves photos

Moves the found photos into the new album

Key Concepts

Simple Agent Creation

Uses default configuration with minimal setup

Structured Output

Returns typed Pydantic model for type-safe results

Direct run_task

No builders needed for simple tasks

Error Handling

Proper try/except/finally pattern

Complete Code

simple_photo_organizer.py

Code Breakdown

1. Define Output Structure

Use detailed field descriptions to help the LLM extract accurate data.

2. Create Agent with Default Config

No configuration needed for simple use cases. The agent will use default settings.

3. Initialize the Agent

This connects to the first available device and starts required servers.
Note that init() is now an async method and must be awaited.

4. Run Task with Structured Output

The result is automatically validated and typed as PhotosResult | None.

5. Always Clean Up

Always call await agent.clean() in a finally block to ensure resources are released. Note that clean() is now an async method.

Running the Example

1

Ensure Prerequisites

  • Device connected with USB debugging enabled
  • ADB installed (Android) or idb installed (iOS)
  • Python 3.12+
2

Install SDK

3

Set up LLM Config

Create llm-config.defaults.jsonc and .env file (see Installation)
4

Run the Script

Expected Output

Customization Ideas

What’s Next

App Lock - Messaging Example

Learn how to restrict execution to a specific app

Smart Notification Assistant

More advanced example with multiple profiles

SDK Reference

Explore the complete SDK