TL;DR: Use suspend { ... } to create a suspending lambda. That is all.

Photo by Rodolfo Clix

When first working with Kotlin coroutines you will quickly come across the suspend keyword as a means of marking a function as a “suspending function”. For example:

Basic format for a suspending function in Kotlin.

There are times, however, where you will run into more exotic usages. Consider the following preview function from the coroutines core library:

This extension allows for a typical suspending function to be converted to a Flow. …

Photo by Immortal shots

In the first article of this series, I discussed what TransactionTooLargeException is, when and why it happens, and how the Bridge library can be used to avoid the problem. If you are not yet familiar with how to use Bridge you should definitely check out that article before continuing. What I’d like to do now is to take a peek inside the library itself and focus on a few tricks used to make it all work. First, though, we have a bit of bookkeeping to discuss.

A quick look at the documentation will show that all the interactions with Bridge

Photo by Zdeno Ceman

TL;DR : Stop worrying about TransactionTooLargeException; use Bridge.

I still remember when I first read the release notes for Android Nougat in the summer of 2016. Buried alongside mostly innocuous changes to things you probably wouldn’t care about was something that jumped out at me:

Many platform APIs have now started checking for large payloads being sent across Binder transactions, and the system now rethrows TransactionTooLargeExceptions as RuntimeExceptions, instead of silently logging or suppressing them. One common example is storing too much data in Activity.onSaveInstanceState(), which causes ActivityThread.StopInfo to throw a RuntimeException when your app targets Android 7.0.

I would…

Brian Yencho

Software Developer at Livefront

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