Photo by Mike Lewis HeadSmart Media on Unsplash

Kotlin Coroutines 1.2.0 introduces cold stream called Flow. It makes easy to cooperate UI and ViewModel (or some your logic).

LiveData as Flow

Create an extension function to treat LiveData as Flow. Flow has the builder like flow and flowViaChannel. To observe LiveData value change and emit it, we should use flowViaChannel builder, becauseflow has only suspend function to emit value then we can’t call it in Observer#onChanged.

LiveData + Two-way Data Binding

This is nothing special. Bounding two LiveData to texts of two EditText using Two-way Data Binding.

Flow + LiveData = Reactive UI

In this article, we’ll implement the incremental GitHub repository search with two EditText. One is inputted the…

Photo by Osman Rana on Unsplash

Kotlin Coroutine is the very easy and high-efficiency async processing mechanism. But, less understanding coroutine scope will cause unintended crashes of your app.


We have to understand below essential specification.

  1. Thrown Exception inside the scope, cancel the scope and all coroutines belonging it (except supervisorScope)
  2. Coroutine builders (like async/launch) don’t create scope
  3. Scope builders (like coroutineScope/withContext) create scope

Handling Exception

If we don’t understand the above specification and Exception Propagation, thrown Exception may through try-catch and crash your application.

This example may seem no problem to handle the exception, but this code will crash caused by RuntimeException.

Because of the specification…

This article shows how can we know user decision on intent chooser you created.

  • requirement: Android 5.1+

If you want know which app was selected by user when showing intent chooser, you should implement the chooser with IntentSender that will callback the user selection.

IntentSender is created from PendingIntent. It means you can/should launch Service or BroadcastReceiver instead of your Activity to prevent interrupting the user operation on the selected app.

Receiver or Service can extract ComponentName as Parcelable from Intent. You can get class name or package name from it.

Photo by Brandi Redd on Unsplash

Google has published Paging Library as part of Android Architecture Components. It makes easier to handle pagination data and show it in RecyclerView.

This library include PagedListAdapter to integrate PagedList data with RecyclerView. We can use this adapter in match the same way as normal RecyclerView.Adapter.

But now, we have excellent libraries to show easily complex items like Groupie.

We’ve to use GroupAdapter to show items in RecyclerView using Groupie. How can we use Paging Library with GroupAdapter?

Reading PagedListAdapter implementation

To understand how PagedListAdapter treat PagedList, let’s see the implementation briefly.

PagedListAdapter should be passed PagedList via submitList method. …

Using SharedPreferences needs some little boilerplate code. And if we store much more data or include/exclude specific data from auto backup, we should consider to split XML file.
Kotpref is the library to make you realizing it simply and ease.

To install, just add app dependency in build.gradle.

And call Kotpref.init(context) function in onCreate at Application class.

Kotpref requires defining data model to save into SharedPreferences. Data model can be created by extending `KotprefModel` like below.

You can now write and read by same way with normal property access!!

Saved SharedPreferences XML through Kotpref is separated…


Android engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store