How app developers can make the most of Android 4.4 KitKat
Google recently announced the new Nexus 5 and the next version of the Android operating system: Android 4.4 KitKat. It also quickly released an updated version of the Android Software Development Kit and the Android Developer Tools. With the SDK and associated tools app developers can now start to tweak their apps to take advantage of the many changes introduced by Android API level 19.
Probably the most useful user interface change in KitKat is the addition of the Full-screen Immersive Mode. This is different from the previous full screen mode as now apps can use 100% of the screen including the areas that were previously occupied by the status and navigation bars. The KitKat API provides two new modes IMMERSIVE and IMMERSIVE_STICKY. These extend the ways an app can work with Android so that users benefit from content at full screen but still allow access to Android’s system level navigation. Of particular interest is the Sticky mode which once set works without really any further interaction from the app. The Immersive Sticky mode shows the status and navigation bars in a semi-transparent state when a user drags from the top of the display. After a short delay they will disappear if the user doesn’t navigate away from the app. Google recommends that apps like book readers and magazine use the new Immersive mode while games and draw apps should use Immersive Sticky. Google have published a short DevBytes guide to these new modes on YouTube and there is also some sample code.
Another addition to the UI tool kit is the new Transitions framework. Transitions allow app developers to define how one scene changes to another scene. This is similar to how scenes transition in a movie with fading or swiping etc. As well as fading in and out there is also the ability to create your own transitions so that different UI elements can be programmed to move, slide, rotate and fade. In fact using custom transitions means you can animate the entry into a scene in any way you want! There is more information in this Android 4.4 Transitions video.
Since KitKat can run on devices with only 512 MB of RAM, there is now a new API call isLowRamDevice() to check if the app is running on a device with less memory. If it is then the app can change its behavior accordingly, maybe cache less data, use lower resolution graphics or pre-load less asserts and so on. KitKat also provides some new tools to available developers to analyze how much memory is being used by their apps. Under System->Developer options there is a new tool called Process Stats which shows the amount of memory being used by different apps. Tapping on a app shows a more detailed analysis including a summary of the memory used with useful stats like the average RAM used and the peak RAM usage.
A great new feature in KitKat is the screen recording tool. It can be accessed by the adb command line tool (e.g. adb shell screenrecord) or via the Android Device Monitor (which is part of the SDK). With it developers will be able to create much higher quality screen recordings for demonstrating their apps or for providing tutorials on how to access more advanced features. Gone are the days of trying to video your app in action via steady hand and a camera.
Android 4.4 KitKat introduces native platform support for printing. The print manager is basically available from within any app and allows the app to generate paper output to supported printers either over Google Cloud Print or via Wi-Fi and Bluetooth. The new platform also lets printer manufacturers create a driver which can be downloaded from the Play Store to allow their brand of printers to work directly from Android. All this is transparent to the app. To add printing support apps need to send either a bitmap, a HTML web view or a PDF to the printing services. The default format is actually PDF, but Google has added some helper classes which take other formats like the bitmaps and automatically convert them to PDF. Check out the DevBytes Android 4.4 Printing API video for more information.
This is just a summary of the most user visible changes in Android 4.4 KitKat but what it shows us is that the perfect KitKat app will use full screen immersive mode with cool scene transitions and have the ability to send output to a printer, while all the time being aware of how much memory is available on the device!