Remote Android Control with Python: Build a Simple PyAndroidControl App

This article introduces PyAndroidControl, a lightweight Android receiver that periodically uploads screenshots to a Python web server for image analysis and returns executable commands, enabling remote device control via cloud phones without needing Java/Kotlin or ADB on a PC.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Remote Android Control with Python: Build a Simple PyAndroidControl App

Sometimes I want to write Android scripts, but using Java or Kotlin for image processing is cumbersome, and learning automation scripts feels unnecessary. While ADB works, it often requires a computer, which can be inconvenient. Cloud phones such as Hongshouzhi or Aiyuntu provide a more convenient way to run continuous tasks.

Therefore I created a basic Android-side receiver that receives control commands from a Python server, allowing remote manipulation of the Android device.

Project repository: https://github.com/nladuo/PyAndroidControl

Architecture Idea

The architecture is simple: an Android client and a web server.

Architecture diagram
Architecture diagram

The app periodically uploads screenshots to the web server. The Python backend can perform image search or other processing on these screenshots, then send back commands that the Android app executes.

Usage Instructions

1. Install PyAndroidControl App

Root permission is required for the app to control the device.

Download the latest release: https://github.com/nladuo/PyAndroidControl/releases

2. Modify the Code According to Your Needs

The provided get_commands function is intended for developers. It takes two parameters: token (a label to identify the user) and img_file (the screenshot from the Android device).

Edit the file simple-control-server/logics.py to implement your own logic.

def get_commands(token, img_file):
    """ analyze the screenshot and send commands back to android device """
    img_file.save("tmp.png")
    print(token)
    # your adb shell commands
    cmds = [
        'input text "111"',
        'input text "222"',
        'input text "333"',
    ]
    return cmds

The example simply sends three ADB commands that input the strings "111", "222", and "333" at one‑second intervals.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Mobile DevelopmentPythonAndroidADBremote control
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.