Exciting things in Android O

William Liu
4 min readJun 4, 2017

Google recently released preview for Android O. After taking a quick look at the major features, I find that there are a lot of exciting changes. From these changes, I can see Android is becoming a better platform and stronger in competing with iOS not only in price, but also on high-end use cases. I don’t want this article becomes another API description from Google (you shall check it out from Google developer website.). So I selected only a few items you I find interesting.

Developer Experience

findViewById()

It is a small change that now you DO NOT need to cast the result to the correct type!! I used to have a wrapper method around it just to do the type casting (actually, the same way as they declare the method now).
```TextView textView = findViewById(R.id.textview)```

View focus

Now if a view is clickable then it will be focusable. I think it is a no-brainer and glad Android O does this by default now. This will save a lot of brain power to remembering to set it to focusable and debugging why something goes wrong…

Downloadable fonts

Many people may not consider fonts is a problem. If you need a font in the app, just include it in the APK, right? Sounds simple but fonts are usually big. Remember there are a lot of Android users (yes, I hate to say that but iOS users are usually have much better data plan and connection). Making the app big means you reduce the install success rate for your app, reduce the upgrade rate.

Allowing fonts to be downloaded on the flight will help to make the app much smaller. The non-default fonts can be downloaded later.

Side note: Instagram Android app is still quite small (only around 22 MB as I write this post)

Unified layout margins and padding

I have been written and seen so many layout_marginTop==layout_marginBottom or layout_marginRight==layout_marginLeft. Now we can set layout_marginVertical and layout_marginHorizontal to set it. It make developer’s life easier if we can set top and bottom, left and right together. Yes, it also applies to padding too.

User Experience

Video Seek to the precise position (as much as possible)

When I was adding a feature to resume video playing, a lot of people asked me the same question after seeing my demo — “why Android does not resume the video to the exact place? I tried iPhone and it resumes correctly.”. I have to explain to each of them that is because of the shitty native support for video in Android. Now Android O finally built this support in natively.

Side note: Exoplayer is a much better player. Use it if you have a choice.

Downloadable emoji.

The emoji is a very important to a app (popular app like Instagram even make it hashtag and is searchable). When I tested on older devices, I can see the “tofu” character in the place of the wonderful emojis. It is major sad moment for users when they see the “tofu”. With the new downloadable support for emoji, the users on older devices can enjoy the new emojis!

Side note: Instagram supports emoji hashtag :)

Webview in separate process

Webview causes a lot of crashes. That is what I learned from working on in-app-browser in Instagram. The main reasons are
1. webpage can consume a lot of resource. Thus causing OOM crashes.
2. Webview has a lot of bugs (especially in the earlier version of Android). These bugs include both security bugs and stability bugs.

Therefore, putting it in a separate process will save the app from crashing if the webview crashes. I am quite happy to see that Google finally put separate process as a native support for Android.

Battery life

No wakelock for cached state app

No high-accuracy location for background app. One common complaint about Android is its battery life. The Android system used to assume all apps are good citizens. But the fact is brutal — some of them are “shitizens” and keep using resource they don’t need. The result is a much shorter battery life for users.

With wakelock, some apps are quietly keeping themselves alive in the background. I am surprised by how long an app was in background whenever I look at the process list.

The new feature releases the wakelock when app enters the cached state with no active components.

Lower accuracy location when app is backgrounded

Therefore many ways to burn the battery, requesting high-accuracy location is one of it. High-accuracy location means requiring GPS on all the time. GPS is very computationally expensive and require a lot of battery.

--

--