Skip to content

Instantly share code, notes, and snippets.

Working on Android Apps

Jonathan Mercandalli Mercandj

Working on Android Apps
View GitHub Profile
Mercandj /
Last active Sep 14, 2020
"Minimal" setup to work on MacOS as an Android Developer

Mac OS Setup

Here my "minimal" setup to work on a Mac as an Android Developer

Mercandj /
Last active Sep 26, 2020
I'm your CTO! As a developer, here the rules I expect you to follow:

Developer: Principles


Like Robert C. Martin would say on this video,

Imagine I'm your CTO, as your CTO I expect you to follow this principles:

Untitled-collage-10-min-9 (1)

Mercandj /
Last active Aug 30, 2020
LiveData: Pros, Cons, Conclusion.

Android: LiveData

Pros, Cons, Conclusion. TLDR; More Cons than Pros.

class Timer {

   private val timeLeftMillis = MutableLiveData(5_000L)
   fun getTimeLeftMillis(): LiveData<Long> {

Android view: Layout IDs creation


Here a ConstraintLayout in a layout containing 2 views:


Mercandj /
Last active Aug 10, 2020
Android: Upload AppBundle on the PlayStore via CLI

Android: Upload AppBundle on PlayStore


Upload AppBundle on the PlayStore via the termial. Based on the Google API Publisher v3.


  • Be sure to have Java installed
  • Be sure to have your AppBundle file .aab

Android: Activity restoration

When you user click Home on any of your activity, the system will save the state of the activity stack and the state of your top-activity.

Then, when your user go back to your application, this activity and the activities stack will be restored on a new JVM.

How to test it?

  • Open your app
  • Go to the activity you want to test

Immutable lists


Immutable lists can be misleading. Here I will use Kotlin. This snippet is viable on Java, C#, Swift... too.

I'm assuming you understand why immutable objects are "more robust" to manipulate data.

Here a "book" with "pages".


Android: Application initialization

On Android, there is a common issue that developers must solve: Deal with heavy load at application start.

1. Application.onCreate()

The easier solution is to put the initialization on the Application

class MainApplication: Application() {
Mercandj /
Last active Jun 26, 2020

Android: Asynchronous

  • This document is to highlight some way to work with asynchronous method on Android.
  • Not vocation to be exhaustive and explicit
  • The goal is for you to pick the good one.

0/ Setup

All following technics will use this setup: methods and interface.

# Parameters: nothing
# Required `$ANDROID_NDK` in your path. For example /Users/jonathan/Library/Android/sdk/ndk-bundle
# Script to generate pre-build opus files
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
if [ -z "$ANDROID_NDK" ]; then
echo "Please set ANDROID_NDK to the Android NDK folder"
You can’t perform that action at this time.