home / skills / partme-ai / full-stack-skills / android-kotlin

android-kotlin skill

/skills/android-kotlin

This skill provides comprehensive guidance for Android development with Kotlin, covering activities, fragments, lifecycle, navigation, and UI components to

npx playbooks add skill partme-ai/full-stack-skills --skill android-kotlin

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
721 B
---
name: android-kotlin
description: Provides comprehensive guidance for Android development with Kotlin including activities, fragments, views, lifecycle, navigation, and Android app development. Use when the user asks about Android Kotlin, needs to create Android applications, implement Android components, or work with Kotlin in Android.
license: Complete terms in LICENSE.txt
---

## When to use this skill

Use this skill whenever the user wants to:
- [待完善:根据具体工具添加使用场景]

## How to use this skill

[待完善:根据具体工具添加使用指南]

## Best Practices

[待完善:根据具体工具添加最佳实践]

## Keywords

[待完善:根据具体工具添加关键词]

Overview

This skill provides practical, hands-on guidance for Android app development using Kotlin. It covers core topics like activities, fragments, views, lifecycle management, navigation, and common app architecture patterns. The guidance focuses on clear examples, implementation patterns, and debugging tips to accelerate development. Use it to learn or solve real implementation problems in Kotlin-based Android projects.

How this skill works

The skill inspects the developer's intent and code context to offer targeted advice: API usage, lifecycle handling, UI composition, navigation, and architecture choices. It provides step-by-step implementation suggestions, sample code snippets, and common pitfalls to avoid. Where appropriate, it suggests modern libraries and patterns (Jetpack components, ViewModel, LiveData/Flow, Navigation, Hilt) and explains trade-offs. It adapts recommendations for app types such as single-activity + fragments or multi-activity approaches.

When to use it

  • When creating or refactoring activities, fragments, and UI layouts in Kotlin.
  • When implementing navigation, back stack handling, and deep links.
  • When handling lifecycle events, background work, and configuration changes.
  • When choosing app architecture (MVVM, MVI) and integrating Jetpack libraries.
  • When debugging crashes, memory leaks, or concurrency issues in Android code.

Best practices

  • Prefer single-activity architecture with Navigation Component for predictable navigation and back-stack handling.
  • Keep UI logic in fragments/activities minimal; use ViewModel for state and business logic.
  • Use Kotlin coroutines and Flow for asynchronous streams; avoid blocking the UI thread.
  • Follow lifecycle-aware patterns (LiveData/Flow, repeatOnLifecycle) to prevent leaks.
  • Leverage dependency injection (Hilt) to make components testable and modular.

Example use cases

  • Build a login flow with Navigation Component, safe-args, and secure token storage.
  • Refactor an app to use ViewModel + StateFlow to preserve UI state across rotations.
  • Implement paging and infinite scroll with Paging 3 and coroutine-based data sources.
  • Fix an intermittent crash caused by accessing views after fragment onDestroyView.
  • Migrate a legacy AsyncTask-based feature to coroutines and WorkManager for background work.

FAQ

Should I use fragments or multiple activities?

Prefer a single-activity with fragments for most apps to centralize navigation and reduce lifecycle complexity; choose multiple activities when strict process isolation or separate tasks are required.

When to use LiveData vs StateFlow?

Use StateFlow for Kotlin-first, coroutine-based architectures and better interoperability with flows; LiveData is fine for simple ViewModel-to-UI bindings and legacy code.