Chromium OS‎ > ‎

Optimize Android Apps for Chromebooks

As announced at Google I/O 2016, Chromebooks will soon support the Google Play Store and Android apps. If you are an Android developer, you may want to learn more. Here is what you should do:


  1. Begin by reviewing the I/O session - “Bring your Android App to Chromebooks.”

  2. Read below for tips to optimize your Android Apps for Chromebooks

  3. Post a question on the Android developer community with hashtag #AndroidAppsOnChromeOS.


In 5 key steps, you can optimize your Android apps for Chromebooks.


1) Update the Android manifest for differences in hardware and software


Start by making a few tweaks to your AndroidManifest.xml file to account for some key differences.  


By default, all Android apps implicitly require touchscreen support. If you want your app to work on all Chromebooks in the best possible way, go to the AndroidManifest.xml and set touchscreen as not required as shown in the example snippet below and look into your mouse & keyboard interactions.


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
         ...>
   <!-- Some Chromebooks don't support touch.

        It's very important to explicitly have this. -->
   <uses-feature android:name="android.hardware.touchscreen"
                 required="false" />
</manifest>


It's worth noting that different devices often have different available sensors in them. While Android handhelds may have GPS and accelerometers, sensors are not guaranteed to be available in every Chromebook. There are cases where the functionality of a sensor is provided in another way. For example, Chromebooks may not have GPS sensors, but they still provide location based on WiFi connections. If you want your app to run on Chromebooks regardless of sensor support, you should set all sensors as not required in the AndroidManifest.xml file.  See here for an overview of all sensors supported in the AndroidManifest.xml file.


Lastly, some software features are unsupported on Chromebooks. For example, apps that provide custom IMEs, app widgets, live wallpapers or home screens/app launchers as shown in the snippet below aren’t supported and won’t be available for installation.   


<uses-feature android:name="android.software.input_methods" />
<uses-feature android:name="android.software.app_widget" />
<uses-feature android:name="android.software.live_wallpaper" />
<uses-feature android:name="android.software.home_screen" />


2) Leverage support for multi-window mode


Good news! The implementation of Android apps on Chrome OS will include basic multi-window support. Instead of automatically drawing over the full screen, Android apps on Chrome OS will be rendered into layouts appropriate for this form factor. Google is providing support for the most common window layouts:


  • Portrait: Similar to Nexus 5

  • Landscape: Similar to Nexus 7

  • Maximized: Uses all available screen pixels


In addition, we added window controls for end-users to toggle between all available layouts. By choosing the correct orientation option, you can make sure the user gets the right layout upon the initial app launch. If an app is available in portrait and landscape, it defaults to landscape and if that is not possible, it will default to portrait view. Once one mode is set that will be remembered on a per app basis.  You might want to see how your app is handline changes of window size and make sure it works well. This will also be useful for Android N in the future.


3) Use the keyboard, trackpad, and mouse


All Chromebooks have a physical keyboard and a trackpad. Some Chromebooks and more coming soon have a touchscreen as well. Some devices can convert from a laptop to a tablet and you will have the opportunity to bring your Android applications to all of these different types of devices.  


Many existing apps already support mouse and trackpad interactions with no extra work required. However it is always a best practice to adjust your behavior where needed when users interact with the app using a trackpad instead of a touchscreen and support and distinguish between both interfaces properly. With a physical keyboard, you can now add support for hotkeys to make users even more productive.


4) Using backup and restore effectively


One of the best features of Chromebooks is that users can just throw their device in a river (please don’t do that), pick up a new one, sign in and all their apps will still be there. Less reconfiguration is required than on an Android device. So, while it is not mandatory, backing up data to the cloud will make a lot of people happier.


Chromebooks can also be shared among a large number of people, as in schools. Of course local storage is not infinite, so at some point whole accounts—together with their storage—can be removed from the device. For school settings, it's a good idea to keep this scenario in mind.


5)  Migrate from M to N


Android apps on Chromebooks will initially ship with Marshmallow APIs. By following the best practices outlined above, you'll be in a much better shape to be compatible with N's multi-window improvements, but it's still a good idea to start planning for N's new APIs and behaviors, which will have several improvements: Multi-window support will become better integrated and you will be able to arbitrarily resize activities, making them feel more natural. In addition, cross-app drag & drop, and mouse cursor APIs will also be available.

Comments