All posts tagged Android

The release of Kotlin 1.1 brings many welcome improvements to the language: val properties with custom getters can take full advantage of type inference and inlining; they introduced the T.also { it -> } extension method, which is to T.apply {} what T.let { it -> } is to {}; and data classes can inherit from interfaces and base classes, just to name a few. But the two biggest changes are full support for JavaScript as a compilation target (possibly a huge deal, if you’re a full stack dev and reluctantly work with JavaScript), and coroutines(!!!).

Continue Reading

If you’re like me, you’ve grudgingly put up with Java for years, for the sake of getting things done on Android. With Kotlin picking up steam as a viable, modern alternative, things are looking much better for all of us. Whenever possible, I do all my Android work in Kotlin.

To reap the fullest benefits of Kotlin, though, we can’t just fall back on old habits; it’s very easy to write code in a familiar Java style. In fact, allowing this was a design goal of Kotlin, to make it easier to transition between languages. But the real power and beauty of Kotlin is where it differs from Java, sometimes drastically. Let’s take a look at some examples of code patterns I’ve run across in production code, and different ways we can improve upon them.

Continue Reading

Android WearIn case it’s helpful to anyone else out there, I had some trouble connecting my phone to a Wear watch.

The gist is, if you pair your phone with the watch from the Bluetooth settings screen instead of the Wear app, the watch will happily connect and try to update/sync, but your phone will never figure out that they’re connected. The first walk-through I read indicated this was how you were supposed to do it, but current versions don’t support this flow. Either this was inaccurate, or an update broke compatibility.

So to save yourself the grief I went through of having to FACTORY RESET YOUR WATCH SO YOU CAN RE-PAIR IT (!!!), make sure you enable Bluetooth in the phone settings, and you can see the watch, but don’t pair with it from there! Do it from the Wear app.

Full, accurate (if spartan) instructions can be found from Google:

Some of you may have noticed that AndroidStudio really wants you to develop for Lollipop–so much so that if you try to create a new project for any of the 4.x versions, it will be broken out of the box. Now, I’m not sure how widespread this problem is, so as a disclaimer, I’ll say I have this problem every time, with the most up-to-date version of AndroidStudio from the Beta channel, on my machine. Here’s some relevant system configuration data:

  • Mac OS X 10.8.5
  • AndroidStudio 1.1.0
  • javac 1.6.0_65
  • Android SDK Build Tools 21.1.2 (with a few older versions still installed)
AndroidStudio 1.1.0

AndroidStudio 1.1.0

Continue Reading