A developer cheat sheet designed for instant desktop reference, university pre-exam revision, and interview preparation. Covers essential lifecycle sequences, Jetpack Compose syntax, Coroutines dispatchers, Room annotations, and essential ADB terminal commands.
| Event | Callback Sequence |
|---|---|
| App Launched | onCreate() -> onStart() -> onResume() (Foreground Active) |
| User Presses Home | onPause() -> onStop() (Hidden in background) |
| User Re-opens App | onRestart() -> onStart() -> onResume() |
| Screen Rotation | onPause() -> onStop() -> onDestroy() -> onCreate() -> onStart() -> onResume() |
// State Declaration
var count by remember { mutableStateOf(0) }
var text by rememberSaveable { mutableStateOf("") } // Survives rotation
// Layout Primitives
Column(modifier = Modifier.fillMaxSize().padding(16.dp)) { ... }
Row(horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically) { ... }
Box(contentAlignment = Alignment.Center) { ... }
// High-Performance Recycled Lists
LazyColumn(verticalArrangement = Arrangement.spacedBy(8.dp)) {
items(myList, key = { it.id }) { item ->
Text(item.name)
}
}
// Observing StateFlow in Compose
val state by viewModel.uiState.collectAsStateWithLifecycle()
// Thread Dispatchers
withContext(Dispatchers.Main) // UI Updates
withContext(Dispatchers.IO) // Network, SQLite, File I/O
withContext(Dispatchers.Default) // CPU-heavy parsing, sorting
// ViewModel Coroutine Launch
viewModelScope.launch {
try {
val result = repository.fetchData()
} catch (e: Exception) {
// Handle error
}
}
// Concurrent Parallel Execution
val data1 = async { fetchA() }
val data2 = async { fetchB() }
val combined = data1.await() + data2.await()
| Annotation | Usage |
|---|---|
@Entity(tableName = "items") |
Marks a Kotlin data class as a SQLite table |
@PrimaryKey(autoGenerate = true) |
Defines the unique auto-incrementing primary key ID |
@ColumnInfo(name = "custom_col") |
Overrides the SQLite table column name |
@Dao |
Marks an interface containing SQL query methods |
@Query("SELECT * FROM items") |
Compile-time verified custom SQL query string |
@Insert(onConflict = REPLACE) |
Inserts or replaces rows on unique constraint collision |
# List all connected physical devices and emulators
adb devices
# Install an APK file onto the connected device
adb install -r app-release.apk
# Uninstall an application
adb uninstall com.veewom.app
# View live filtered Logcat crash output
adb logcat *:E
# Launch an Activity directly via Intent
adb shell am start -n com.veewom.app/.MainActivity
# Trigger an Android App Link deep link
adb shell am start -W -a android.intent.action.VIEW -d "https://veewom.com/android/42" com.veewom.app
# Take a screenshot and pull to your PC
adb shell screencap -p /sdcard/screen.png
adb pull /sdcard/screen.png .
Broaden your foundational and advanced Android application development skills across our curriculum:
Return to the master curriculum overview and 8 learning modules.
Comprehensive technical interview questions and answers.
University examination guide and project viva preparation.
Put cheat sheet snippets into action across 35+ real projects.