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
- Avoid Async tasks, really do not use them. Kotlin coroutines () or RxJava are much nicer to use.
- Don’t use Loaders, if you don’t know what they are don’t bother really.
- Don’t use bare threads or manage them on your own.
Clean Code
- Use a dependency injection framework, Koin is great to start with.
- Avoid dagger in your first project.
- Don’t use Guice!
UI
- Use Jetpack Components instead of the original Android Support Libraries. And when going through old tutorials remember to replace dependencies with their
andoridx.*
equivalent. - 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.
- Don’t use headless fragments for communicating between them within an activity. Maintain view state via ViewModels and shared ViewModels instead.
-
ConstraintLayout
is great, give it a try. - Use
RecyclerView
instead ofListView
,GridView
,GridLayout
, … - Favor Jetpack Fragments over platform Fragments.
Push notifications
- GCM is deprecated, use FCM instead.
- 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
- Eclipse, what is that! Android Studio is great.
- Use Room if you need to manage your internal databases. You can use them with Kotlin coroutines as well.
- Use exo player for audio and video playback.
- Use Kotlin instead of Java and make use of what Kotlin has to offer instead of writing Java code disguised in Kotlin syntax.
-
DownloadService
is still great. - Keep an eye on Compose.
© 版权声明
THE END
暂无评论内容