Skip to content
Agent

02-platform

by pluginagentmarketplace

AI Summary

A comprehensive Android platform specialist agent that teaches core components (Activities, Fragments, Services, Lifecycle, Intents, Permissions) across 78 hours of structured content. Ideal for developers building Android apps who need expert guidance on system-level architecture and lifecycle management.

Install

Copy this and paste it into Claude Code, Cursor, or any AI assistant:

I want to set up the "02-platform" agent in my project.

Please run this command in my terminal:
# Add AGENTS.md to your project root
curl --retry 3 --retry-delay 2 --retry-all-errors -o AGENTS.md "https://raw.githubusercontent.com/pluginagentmarketplace/custom-plugin-android/main/agents/02-platform.md"

Then explain what the agent does and how to invoke it.

Description

Android core components - Activities, Fragments, Services, Lifecycle, Intent system, Permissions (78 hours)

Platform Agent: Android Core Components & Lifecycle Management

Master Android's component model and lifecycle management. Understand Activities, Fragments, Services, and how they interact through Intents. Learn to handle configuration changes, manage background operations, and implement proper permission handling. Prerequisite: Fundamentals agent (Kotlin, OOP, SOLID) Duration: 78 hours | Level: Beginner to Intermediate Topics: 8 major areas | Code Examples: 35+ real-world patterns ---

1. ACTIVITY LIFECYCLE & MANAGEMENT

Activities are the visible UI component lifecycle. Understanding the complete lifecycle is critical for proper state management.

1.1 Complete Activity Lifecycle (6 States)

` onCreate → onStart → onResume → [USER INTERACTION] ↓ onPause → onStop → onDestroy ↑_________| (User returns) ` Complete Lifecycle with Callbacks: `kotlin class MainActivity : AppCompatActivity() { // 1. onCreate(): Called when activity is first created // When: Process created OR activity created (not killed) // State: Activity NOT visible, can initialize UI and restore state override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) // Initialize UI components val viewModel: MainViewModel by viewModels() // Restore saved instance state savedInstanceState?.let { val savedValue = it.getString("key") } } // 2. onStart(): Called when activity becomes visible // When: After onCreate OR after onStop // State: Activity visible but NOT in foreground // Note: onStart ↔ onStop protect "visible" resource acquisition override fun onStart() { super.onStart() registerSensorListener() // Acquire resources } // 3. onResume(): Called when activity gains focus // When: After onStart OR after onPause // State: Activity in foreground, receives user input // Note: onResume ↔ onPause protect "focused" resource acquisition override fun onResume() { super.onResume() startCamera() // Camera requires focus startAnimation() // Resume animations } // 4. onPause(): Called when activity loses focus // When: Another activity gains focus (transparent or translucent) // State: Activity partially visible but NOT in foreground // Critical: Keep this short! Next activity won't start until this finishes override fun onPause() { super.onPause() stopCamera() // Release focus-dependent resources pauseAnimation() // Pause animations } // 5. onStop(): Called when activity is no longer visible // When: Another activity fully covers this OR user navigates away // State: Activity NOT visible to user override fun onStop() { super.onStop() unregisterSensorListener() // Release resources saveSessionData() } // 6. onDestroy(): Called before activity is destroyed // When: Activity finishing OR system destroying to free memory // State: Activity being removed from memory override fun onDestroy() { super.onDestroy() viewModel.cleanup() // Final cleanup } } `

1.2 Configuration Changes (Rotation, Locale, etc.)

By default, configuration change (e.g., rotation) destroys and recreates activity: ` [Current State] → onPause → onStop → onDestroy → onCreate → onStart → onResume [NEW State] ` Problem: User data lost! Solution: Save/Restore state Option 1: Handle in onSaveInstanceState `kotlin class DataActivity : AppCompatActivity() { private var userData: String = "" override fun onSaveInstanceState(outState: Bundle) { super.onSaveInstanceState(outState) // Called BEFORE onStop, guaranteed to be called before destroy outState.putString("user_data", userData) } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) savedInstanceState?.let { userData = it.getString("user_data", "") } } } ` Option 2: Prevent Recreation with configChanges `xml <!-- AndroidManifest.xml --> <activity android:name=".MainActivity" android:configChanges="orientation|screenSize" android:screenOrientation="portrait" /> ` When handled: ` [Current State] → onPause → onStop → onConfigurationChanged → onStart → onResume [State Preserved!] ` Option 3: Use ViewModel (RECOMMENDED) `kotlin @HiltViewModel class DataViewModel @Inject constructor( private val repository: DataRepository ) : ViewModel() { // ViewModel survives configuration changes! private val _userData = MutableLiveData<User>() val userData: LiveData<User> = _userData } class DataActivity : AppCompatActivity() { private val viewModel: DataViewModel by viewModels() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // ViewModel already has data from previous configuration viewModel.userData.observe(this) { user -> updateUI(user) } } } `

Discussion

0/2000
Loading comments...

Health Signals

MaintenanceCommitted 3mo ago
Stale
AdoptionUnder 100 stars
1 ★ · Niche
DocsREADME + description
Well-documented

GitHub Signals

Stars1
Issues0
Updated3mo ago
View on GitHub
No License

My Fox Den

Community Rating

Sign in to rate this booster

Works With

Claude Code
Claude.ai