Skip to content

frostyshadows/android-cheatsheet

Repository files navigation

Android Cheatsheet

This is a collection of visual guides that I find myself coming back to repeatedly while doing Android development. Open to contributions!

Table of contents

Activities and Fragments

User interface

Kotlin

Jetpack Compose

Architecture

Build process

General software engineering

Activities and Fragments

Lifecycle flowchart

Callback methods

Callback When What Is Activity visible
onCreate() Activity is first created All the necessary UI elements should be initialized no
onStart() Activity becomes visible to user Code that maintains the UI, start async tasks (get data from API or database), register listeners yes
onResume() Activity becomes interactable to user Starts animations yes
onPause() User is leaving the activity Stops animations partially visible
onStop() Activity is no longer visible to user Unregisters listeners and resources allocated in onStart() no
onRestart() Activity in the stopped state is about to start again (on back click) Cursor objects should be re-queried no
onDestroy() Activity is destroyed from memory no

Launch modes

Mode Default Instantiation New Task on Launch Allow other activities within Task
standard Yes Everytime an intent is created, a new instance is created. Also instances can be member of multiple tasks and more than one instance in a Task. No. Open in the same Task that originated the intent Yes
singleTop No Exactly like standard but if the activity is at the top of the Task stack then it uses the existing instance. No. Open in the same Task that originated the intent Yes
singleTask No Single instance Yes. Always a Root Task. Yes
singleInstance No Single instance Yes. Always a Root Task. Never. Always the only activity in the task

Source

User interface

RecyclerView pieces

Piece What it does
RecyclerView The ViewGroup that contains the views corresponding to your data.
item One data item of the list to display. Can be of any type; often a data class you define.
Adapter Takes data and prepares it for RecyclerView to display.
ViewHolders A pool of views for RecyclerView to use and reuse to display items. Each individual ViewHolder is a wrapper around a View.
View A layout that can display one data item.
LayoutManager Measures and positions individual item views within a RecyclerView and determines the policy for when to recycle item views that are no longer visible. The ones provided in the RecyclerView library are LinearLayoutManager, GridLayoutManager, and StaggeredGridLayoutManager

Source

ImageView ScaleTypes

Source

PorterDuff modes for tinting

Source

Kotlin

Kotlin Standard Library functions

Type system

Source

Kotlin Flow Cheatsheet

Source

Jetpack Compose

Three phases of a frame

Source

Choosing an API to implement an animation

Source

Arrangement

Horizontal arrangements in Rows Vertical arrangements in Columns

Source

Architecture

Uncle Bob's clean architecture

Source

Build process

Source

General software engineering

Code review checklist

Source

Gang of Four design patterns

Source

About

Helpful visual guides for Android development

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published