Tuesday, November 5, 2013

What Android 4.4 KITKAT version brings to you?

KITKAT or Android 4.4 is the latest version of android after JELLYBEAN. From the feature wise perspective KITKAT does not have much to boast.
In the  Android website, they say "Android 4.4 is designed to run fast, smooth, and responsively on a much broader range of devices than ever before — including on millions of entry-level devices around the world that have as little as 512MB RAM."

For developers they have introduced some new API's and tools to create responsive and memory efficient applications.

1.   RAM Memory Management:
A new API, ActivityManager.isLowRamDevice(), lets you tune your app's behavior to match the device's memory configuration. You can modify or disable large-memory features as needed, depending on the use-cases you want to support on entry-level devices.

           //Check if device is memory constrained
ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
boolean lowRam = ActivityManager.isLowRamDevice();
if (lowRam) {
// Modify memory use behavior
2.   Tools for analyzing memory use:
Procstats is a new tool for analyzing memory resources your app uses, as well as the resources used by other apps and services running on the system.

Procstats keeps track of how apps are running over time, providing data about their execution durations and memory use to help determine how efficiently they are performing. This is most important for apps that start services that run in the background, since it lets you monitor how long they are running and how much RAM they are using while doing so.

For accessing this tool go to command prompt and enter this command, "adb shell dumpsys procstats"

3.   Full-screen Immersive mode:
Android 4.4 adds a new full-screen immersive mode that lets you create full-bleed UIs reaching from edge to edge on phones and tablets, hiding all system UI such as the status bar and navigation bar.
And to make sure that users always have easy, consistent access to system UI from full-screen immersive mode, Android 4.4 supports a new gesture — in immersive mode, an edge swipe from the top or bottom of the screen now reveals the system UI.

//Code to hide
private void hideSystemUI()

//Code to show
private void showSystemUI()

4.   Transitions framework for animating scenes:
To create high-quality animations in your app, Android 4.4 introduces a new transitions framework. With the transitions framework you can also animate changes to your UI on the fly.

Using code,
ChangeBounds(); Fade(); functions are used.
TransitionSet set = new TransitionSet();
set.addTransition(new ChangeBounds()).addTransition(new Fade());

Using resource,

5.   Screen Recording:
Now it's easy to create high-quality video of your app, directly from your Android device. Android 4.4 adds support for screen recording and provides a screen recording utility that lets you capture video as you use the device and store it as an MP4 file. It's a great new way to create walkthroughs and tutorials for your app, testing materials, marketing videos, and much more.
For accessing this type "adb shell screenrecord" in command prompt.

If your app plays video or other protected content that you don't want to be captured by the screen recorder, you can use SurfaceView.setSecure() to mark the content as secure.

6.   Closed Captioning:
VideoView can use a new API to pass a captioning stream along with a video stream for rendering. The system automatically handles the display of the captions on video frames according to the user's systemwide settings.

//Add local source for English
subtitles. mVideoView.addSubtitleSource(
getResources .openRawResource (R. raw. subs_en_vtt) ,
MediaFormat.createSubtitleFormat(text/vtt", Locale.ENGLISH.getLanguage()));

// Add local source for French
subtitles. mVideoView.addSubtitleSource(
getResources().openRawResource(R.raw.subs_fr vtt),
MediaFormat.createSubtitleFormat("text/vtt", Locale .FRENCH.getlanguage() ) ) ;

7.   Translucent system UI styling:
To get the most impact out of your content, you can now use new window styles and themes to request translucent system UI, including both the status bar and navigation bar.

8.   Chromium WebView:
Android 4.4 includes a completely new implementation of WebView that's based on Chromium. The new Chromium WebView gives you the latest in standards support, performance, and compatibility to build and display your web-based content.
Chromium WebView provides broad support for HTML5, CSS3, and JavaScript. It supports most of the HTML5 features available in Chrome for Android 30. It also brings an updated version of the JavaScript Engine (V8) that delivers dramatically improved JavaScript performance.

9.   SMS provider:
If you develop a messaging app that uses SMS or MMS, you can now use a shared SMS provider and new APIs to manage your app's message storage and retrieval. The new SMS provider and APIs define a standardized interaction model for all apps that handle SMS or MMS messages.

10. Storage access framework:
A new storage access framework makes it simple for users to browse and open documents, images, and other files across all of their their preferred document storage providers. A standard, easy-to-use UI lets users browse files and access recents in a consistent way across apps and providers.

11. Printing framework:
Android 4.4 introduces native platform support for printing, along with APIs for managing printing and adding new types of printer support. The platform provides a print manager that mediates between apps requesting printing and installed print services that handle print requests. The print manager provides shared services and a system UI for printing, giving users consistent control over printing from any app. The print manager also ensures the security of content as it's passed across processes, from an app to a print service.

·         Printer manufacturers can use new APIs to develop their own print services
·         Client apps can use new APIs to add printing capabilities to their apps with minimal code changes
void doBitmapPrint() {
PrintHelper bitmapPrinter = new PrintHelper(getactivity());
bitmapPrinter.setScaleMode( PrintHelper.SCRLE_MODE_FIT);
Bitmap bitmap = BitmapFactory.decodeResource( getResources(), R.drawable.droids):
bitmapPrinter.printBitmap( "droids.jpg - test print", bitmap);
12. Sensor batching:
Android 4.4 introduces platform support for hardware sensor batching, a new optimization that can dramatically reduce power consumed by ongoing sensor activities.

13. Step Detector and Step Counter:
Android 4.4 also adds platform support for two new composite sensors — step detector and step counter — that let your app track steps when the user is walking, running, or climbing stairs. These new sensors are implemented in hardware for low power consumption.

14. Host Card Emulation:
Android 4.4 introduces new platform support for secure NFC-based transactions through Host Card Emulation (HCE), for payments, loyalty programs, card access, transit passes, and other custom services. With HCE, any app on an Android device can emulate an NFC smart card, letting users tap to initiate transactions with an app of their choice