paint-brush
Don’t write Android apps like it’s 2009!by@mgazar
406 reads
406 reads

Don’t write Android apps like it’s 2009!

by Mostafa GazarDecember 11th, 2019
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Android Pro, built million-downloads app, YC alumni. I write about Machine Learning and Mobile. The following is based on my experience working on various Android apps for the past few years and seeing how the framework and the development ecosystem evolved over time. The recommendation now is to build single Activity applications (or small number of activities) which contradicts the old advice of having a ton of activities. The recommendations now are to build one Activity applications. The recommendation is to use Jetpack Components instead of the original Android Support Libraries.

Company Mentioned

Mention Thumbnail
featured image - Don’t write Android apps like it’s 2009!
Mostafa Gazar HackerNoon profile picture

https://en.wikipedia.org/wiki/HTC_Dream

The following is based on my experience working on various Android apps for the past few years and seeing how the framework and the development ecosystem evolved over time.

Concurrency

  1. Avoid Async tasks, really do not use them. Kotlin coroutines (👍) or RxJava are much nicer to use.
  2. Don’t use Loaders, if you don’t know what they are don’t bother really.
  3. Don’t use bare threads or manage them on your own.

Clean Code

  1. Use a dependency injection framework, Koin is great to start with.
  2. Avoid dagger in your first project.
  3. Don’t use Guice!

UI

  1. Use Jetpack Components instead of the original Android Support Libraries. And when going through old tutorials remember to replace dependencies with their 
    andoridx.*
     equivalent.
  2. The recommendation now is to build single Activity applications (or small number of activities) which contradicts the old advice of having a ton of activities. JetPack navigation works great if you follow this advice.
  3. Don’t use headless fragments for communicating between them within an activity. Maintain view state via ViewModels and shared ViewModels instead.
  4. ConstraintLayout
     is great, give it a try.
  5. Use 
    RecyclerView
     instead of 
    ListView
    GridView
    GridLayout
    , …
  6. Favor Jetpack Fragments over platform Fragments.

Push notifications

  1. GCM is deprecated, use FCM instead.
  2. Starting in Android 8.0 (API level 26), all notifications must be assigned to a channel, without a notification channel, the notification will not appear and the system logs an error.

Other

  1. Eclipse, what is that! Android Studio is great.
  2. Use Room if you need to manage your internal databases. You can use them with Kotlin coroutines as well.
  3. Use exo player for audio and video playback.
  4. Use Kotlin instead of Java and make use of what Kotlin has to offer instead of writing Java code disguised in Kotlin syntax.
  5. DownloadService
     is still great.
  6. Keep an eye on Compose.

Share it and get it in touch, my Twitter DMs are open!