Published in ProAndroidDev·Jan 10, 2022Member-onlyInterpreting voice results for Android media apps in carsWhen working on the Android Auto integration for SoundCloud, I stumbled upon an interesting issue. When it comes to implementing voice actions, things you read in the documentation might differ a bit from reality. Voice commands are very critical while driving a car. You want the driver to keep looking…Android3 min readAndroid3 min read
Published in Google Developer Experts·Jun 14, 2021Using the Kotlin standard library from JavaIf you work with Kotlin on a daily basis you probably love the language and don’t want to go back to Java. Though, many of us work on a codebase that isn’t purely Kotlin. Our Android codebase at SoundCloud still has a fair amount of code written in Java. This…Kotlin4 min readKotlin4 min read
Published in ProAndroidDev·May 31, 2021Member-onlyThe Kotlin modifier that shouldn't be thereMost Kotlin developers would agree that a val property is equivalent to a final property in Java. What if I tell you that this is not completely true and sometimes you might need a final val? Opposite to Java, Kotlin properties are final by default unless they are explicitly marked…Kotlin4 min readKotlin4 min read
Published in Google Developer Experts·Jan 12, 2021Avoid backing properties for LiveData and StateFlowIf you have ever worked with LiveData you probably have written code similar to this: class MyViewModel: ViewModel() { val loading: LiveData<Boolean> get() = _loading private val _loading = MutableLiveData<Boolean>() } This seems nowadays the typical way developers would expose some immutable LiveData, while being able to have a mutable…Kotlin5 min readKotlin5 min read
Published in ProAndroidDev·Jan 4, 2021When “Compat” libraries won’t save youAnd why you should avoid using the “NewApi” suppression! The idea of “Compat” libraries was probably one of the key aspects of Android dominating the mobile space. Other than with iOS, Android users often could not update their operating system after a new version launch, simply as their phones won’t…Kotlin5 min readKotlin5 min read
Published in Google Developer Experts·Dec 15, 2020When LiveData and Kotlin don’t play well togetherThe idea of LiveData was an interesting one. Based on the idea of reactive streams, that was on the peak at that time with RxJava plus adding automatic lifecycle handling — a problem on Android. LiveData had bad timing though. It arrived just before Kotlin made its impact in the…Kotlin4 min readKotlin4 min read
Published in The Startup·Dec 7, 2020Swift’s Guard Statement for KotlinEven if you live on the Kotlin side of things maybe once in a while you also check Swift code. If you do, you probably noticed how similar both languages are. To me, Kotlin looks more concise but I’m also biased as I work with Kotlin daily. On the other…Kotlin6 min readKotlin6 min read
Published in Google Developer Experts·Jul 28, 2020Hidden pitfalls when using Elvis operatorI guess many of us love Elvis, both the artist and the operator in Kotlin. But it can lead to some hidden pitfalls if you are not aware of how it works. I only realized recently when Vladimir Zdravkovic put some code on twitter and ask us to guess what…Kotlin3 min readKotlin3 min read
Published in ProAndroidDev·Jul 16, 2020Member-onlyKeep your interfaces simpleAvoiding implicit connections and learn how extension functions can help you writing good APIs — Writing your classes with a good API is hard but important. As the writer is trying to make it easy for the user, we sometimes tend to repeat ourselves by adding convenient methods. Think about the List interface in Java. To check if there are no elements in the list…Kotlin3 min readKotlin3 min read
Published in ProAndroidDev·Jun 22, 2020The forgotten art of constructionHow tools made us forget how to write sane constructors In an ideal world, developers get smarter every day. The code we write this year should be better than the code we wrote 10 years ago, which in turn should be better than the code 20 years ago. …Kotlin6 min readKotlin6 min read