android-development

Android development patterns for Kotlin/Java including MediaProjection, Accessibility Service, Socket.IO, and foreground services. Use when working on TitanMirror or other Android projects.

16 stars

Best use case

android-development is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Android development patterns for Kotlin/Java including MediaProjection, Accessibility Service, Socket.IO, and foreground services. Use when working on TitanMirror or other Android projects.

Teams using android-development should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/android-development/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/development/android-development/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/android-development/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How android-development Compares

Feature / Agentandroid-developmentStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Android development patterns for Kotlin/Java including MediaProjection, Accessibility Service, Socket.IO, and foreground services. Use when working on TitanMirror or other Android projects.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# 📱 Android Development Skill

## Use Cases
- Screen mirroring (MediaProjection)
- Remote control (Accessibility Service)
- Real-time communication (Socket.IO)
- Background services

---

## MediaProjection Setup

### 1. Request Permission
```kotlin
val mediaProjectionManager = getSystemService(MEDIA_PROJECTION_SERVICE) as MediaProjectionManager
startActivityForResult(mediaProjectionManager.createScreenCaptureIntent(), REQUEST_CODE)
```

### 2. Create Projection
```kotlin
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {
        mediaProjection = mediaProjectionManager.getMediaProjection(resultCode, data!!)
        startCapture()
    }
}
```

### 3. ImageReader for Frames
```kotlin
val imageReader = ImageReader.newInstance(width, height, PixelFormat.RGBA_8888, 5)
imageReader.setOnImageAvailableListener({ reader ->
    val image = reader.acquireLatestImage()
    // Process frame...
    image?.close()
}, handler)
```

---

## Foreground Service (Android 14+)

> ⚠️ **CRITICAL**: Must call `startForeground()` immediately in `onStartCommand()`

```kotlin
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
    // FIRST: Start foreground immediately!
    val notification = createNotification()
    startForeground(NOTIFICATION_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION)
    
    // THEN: Extract intent and start work
    val resultCode = intent?.getIntExtra("resultCode", -1) ?: -1
    val data = intent?.getParcelableExtra("data", Intent::class.java)
    
    // Add delay before capture
    Handler(Looper.getMainLooper()).postDelayed({
        startCapture(resultCode, data)
    }, 1500)
    
    return START_NOT_STICKY
}
```

---

## Socket.IO Connection

```kotlin
val socket = IO.socket("http://192.168.1.x:3000")

socket.on(Socket.EVENT_CONNECT) {
    Log.d("Socket", "Connected!")
    socket.emit("register", deviceInfo)
}

socket.on("command") { args ->
    val command = args[0] as JSONObject
    handleCommand(command)
}

socket.connect()
```

---

## Accessibility Service

```kotlin
class RemoteControlService : AccessibilityService() {
    
    override fun onAccessibilityEvent(event: AccessibilityEvent?) {
        // Handle accessibility events
    }
    
    fun performClick(x: Int, y: Int) {
        val path = Path().apply { moveTo(x.toFloat(), y.toFloat()) }
        val gesture = GestureDescription.Builder()
            .addStroke(GestureDescription.StrokeDescription(path, 0, 100))
            .build()
        dispatchGesture(gesture, null, null)
    }
    
    fun performSwipe(startX: Int, startY: Int, endX: Int, endY: Int) {
        val path = Path().apply {
            moveTo(startX.toFloat(), startY.toFloat())
            lineTo(endX.toFloat(), endY.toFloat())
        }
        val gesture = GestureDescription.Builder()
            .addStroke(GestureDescription.StrokeDescription(path, 0, 300))
            .build()
        dispatchGesture(gesture, null, null)
    }
}
```

---

## Decision Tree

```
Android task?
├── Screen capture? → MediaProjection + ImageReader
├── Background work? → Foreground Service (Android 14 rules!)
├── Remote control? → Accessibility Service
├── Network comm? → Socket.IO
└── Permissions? → Runtime request + Manifest
```

---

## Common Pitfalls

| ปัญหา | สาเหตุ | แก้ไข |
|-------|--------|-------|
| Black screen | startForeground timing | Call immediately in onStartCommand |
| Crash on Android 14 | Wrong intent extraction | Use `getParcelableExtra(key, Class)` |
| Low FPS | Buffer too small | Increase ImageReader buffer to 5 |
| Service killed | Not foreground | Add FOREGROUND_SERVICE permission |

Related Skills

argentic-framework-development

16
from diegosouzapw/awesome-omni-skill

Expert knowledge for building AI agents with Argentic - a Python microframework for async MQTT-based agents with multi-LLM support, custom tools, and multi-agent orchestration

API Development

16
from diegosouzapw/awesome-omni-skill

Meta-skill that orchestrates the full API development lifecycle — from design through documentation — by coordinating specialized skills, agents, and commands into a seamless build workflow.

api-development-expert

16
from diegosouzapw/awesome-omni-skill

API development expert including REST design, OpenAPI, and documentation

android

16
from diegosouzapw/awesome-omni-skill

Build, review, and refactor Android mobile apps (Kotlin) using modern Android patterns. Use for tasks like setting up Gradle modules, Jetpack Compose UI, navigation, ViewModel/state management, networking (Retrofit/OkHttp), persistence (Room/DataStore), DI (Hilt/Koin), testing, performance, release builds, and Play Store readiness.

android-watch-logs

16
from diegosouzapw/awesome-omni-skill

Start real-time log streaming from connected Android device using adb logcat. Shows only app's log messages. Use when monitoring app behavior, debugging, or viewing Android logs.

android-use

16
from diegosouzapw/awesome-omni-skill

Control Android devices via ADB commands - tap, swipe, type, navigate apps

android-supabase

16
from diegosouzapw/awesome-omni-skill

Supabase integration patterns for Android - authentication, database, realtime subscriptions. Use when setting up Supabase SDK, implementing OAuth, querying database, or setting up realtime.

android-stop-app

16
from diegosouzapw/awesome-omni-skill

Stop the Android app running on connected device. Cleanly terminates the app using force-stop. Use when stopping the app for debugging, testing, or cleanup.

android-project

16
from diegosouzapw/awesome-omni-skill

Navigate and analyze Android project structure, modules, and dependencies. Use when exploring project structure, finding related files, analyzing dependencies, or locating code patterns.

android-notification-builder

16
from diegosouzapw/awesome-omni-skill

Эксперт Android notifications. Используй для push notifications, channels и notification patterns.

android-motion-specialist

16
from diegosouzapw/awesome-omni-skill

Expert Android developer for the Motion Detector project. Use this skill when working on Camera2 API integration, motion detection algorithms, Android networking (LAN sockets + Supabase Realtime), debugging crashes, or any Android/Kotlin development tasks specific to this sprint timing application.

android-kotlin

16
from diegosouzapw/awesome-omni-skill

Android Kotlin development with Coroutines, Jetpack Compose, Hilt, and MockK testing