
{"id":1451,"date":"2015-01-16T18:55:09","date_gmt":"2015-01-16T18:55:09","guid":{"rendered":"http:\/\/www.codergears.com\/Blog\/?p=1451"},"modified":"2015-01-19T21:18:02","modified_gmt":"2015-01-19T21:18:02","slug":"discovering-the-evolution-of-the-android-apis","status":"publish","type":"post","link":"https:\/\/codergears.com\/Blog\/?p=1451","title":{"rendered":"Discovering the Android APIs evolution."},"content":{"rendered":"<p>According to <a href=\"http:\/\/www.idc.com\/prodserv\/smartphone-os-market-share.jsp\">IDC\u00a0<\/a>\u00a0Android is the most popular mobile operating system in the world. Nothing new there, for many years android was the leader. But, what&#8217;s amazing is the growth percent between 2011 and 2014.<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/Android8.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1460\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/Android8.png\" alt=\"Android8\" width=\"694\" height=\"208\" \/><\/a><\/p>\n<p><!--more-->Each day many new android apps are available,\u00a0these apps are developed using the Android APIs, Google provides\u00a0on\u00a0a regular basis new updates and improvements to their APIs. Let&#8217;s discover the evolution \u00a0of the Android APIs by comparing\u00a0the Android4.4.4\u00a0with\u00a0the new major version\u00a0Android5.0.0\u00a0using <a href=\"http:\/\/www.jarchitect.com\">JArchitect<\/a>.<\/p>\n<p>Here&#8217;s a summary of changes between the two versions:<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/android11.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1465\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/android11.png\" alt=\"android1\" width=\"622\" height=\"329\" \/><\/a><\/p>\n<p>The API growths by\u00a015%. Many\u00a0packages, classes and methods are added which is a good a indicator that many new features were introduced in the new major API. \u00a0However the cyclomatic complexity average was increased \u00a0by 4%.<\/p>\n<p><strong>Features added<\/strong><\/p>\n<p>The Android APIs adopt\u00a0the package by feature approach.\u00a0Package-by-feature uses packages to reflect the feature set. It places all items related to a single feature (and only that feature) into a single directory\/package. This results in packages with high cohesion and high modularity, and with minimal coupling between packages. Items that work closely together are placed next to each other.<\/p>\n<p>Therefore the best way to discover the features added is to search for the new packages introduced:<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/Android21.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1466\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/Android21.png\" alt=\"Android2\" width=\"447\" height=\"539\" \/><\/a><\/p>\n<p>Some of them existed before like com.android.mms.*. they were\u00a0<span style=\"color: #555555;\">\u00a0present on the device but not in the sdk. In the new major sdk version, these packages and their classes are now prenst in the SDK.<\/span><\/p>\n<p>Some others were added to structure better the SDK, like android.server.backup which contains now classes like\u00a0BackupManagerService moved from android.server.<\/p>\n<p>And others are added to provide new features:<\/p>\n<p><em>com.android.okio<\/em>:\u00a0<span style=\"color: #333333;\"><a href=\"https:\/\/github.com\/square\/okio\">Okio <\/a>is a new library that complements\u00a0<\/span><code style=\"color: #333333;\">java.io<\/code><span style=\"color: #333333;\">\u00a0and\u00a0<\/span><code style=\"color: #333333;\">java.nio<\/code>\u00a0to make it much easier to access, store, and process your data. And now its included to the Android SDK.<\/p>\n<p><em>com.android.server.usage<\/em> which provides \u00a0a\u00a0service that collects, aggregates, and persists application usage data.<\/p>\n<p><em>com.android.server.voiceinteraction<\/em>\u00a0which provides classes needed\u00a0to \u00a0treat the interaction with the user by using voice.<\/p>\n<p>com.android.server.tv which provides useful classes to manage the televesion features.<\/p>\n<p>com.android.ims\u00a0which\u00a0provides many classes to manage IMS feature.<\/p>\n<p>android.telecom\u00a0which provides access to Telecom-related functionality.<\/p>\n<p>android.service.fingerprint\u00a0which provides\u00a0\u00a0classes to manage\u00a0the fingerprint feature.<\/p>\n<p><strong>Added Annotations<\/strong><\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/Android10.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1485\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/Android10.png\" alt=\"Android10\" width=\"325\" height=\"496\" \/><\/a><\/p>\n<p>Some annotations were added. Maybe the most interesting one is the Nullable one which\u00a0denotes that a parameter, field or method return value can be null.\u00a0When decorating a method call parameter, this denotes that the parameter can legitimately be null and the method will gracefully deal with it. Typically used on optional parameters.When decorating a method, this denotes the method might legitimately return null.<\/p>\n<p><strong>Added Interfaces<\/strong><\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/Android111.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1486\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/Android111.png\" alt=\"Android11\" width=\"328\" height=\"498\" \/><\/a><\/p>\n<p>Interfaces are the recommended way to define the contract of provided features. Many interfaces were added in the new packages to abstract these new features. And the best way to know each feature capabilities is to search for its interfaces, and discover the methods defined by them.<\/p>\n<p><strong>Added Classes to the existing packages<\/strong><\/p>\n<p>Many useful classes were added to the existing packages to provide\u00a0some recurrent technical needs.<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/Android12.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1487\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/Android12.png\" alt=\"Android12\" width=\"534\" height=\"501\" \/><\/a><\/p>\n<p>As we can remark, many\u00a0of them are internals and exist in the com.android.internal.* packages. However, we can search for added classes not in the internal packages:<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/Android14.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1490\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/Android14.png\" alt=\"Android14\" width=\"422\" height=\"508\" \/><\/a><\/p>\n<p>Classes are added in many packages, developers should care about some of them, they could facilitate the developement of some features. For example the PdfRenderer\u00a0could be useful when rendering to pdf capability is needed.<\/p>\n<p><strong>Methods added to the existing Classes<\/strong>:<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/Android41.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1468\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/Android41.png\" alt=\"Android4\" width=\"445\" height=\"520\" \/><\/a><\/p>\n<p>Many useful methods were added to the existing classes, The following metric view shows their distribution inside the code base.<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/Android51.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1469\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/Android51.png\" alt=\"Android5\" width=\"711\" height=\"410\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>In the Metric View, the code base is represented through a Treemap. Treemapping is a method for displaying tree-structured data by using nested rectangles. The tree structure used \u00a0is the usual code hierarchy:<\/p>\n<ul style=\"color: #333333;\">\n<li>Project contains packages.<\/li>\n<li>Package contains types.<\/li>\n<li>Type contains methods and fields.<\/li>\n<\/ul>\n<p style=\"color: #333333;\">The treemap view provides a useful way to represent the result of a CQLinq request; the blue rectangles represent this result, so we can visually see the methods\u00a0concerned by the request.And as we can observe the added methods are distributed in almost all packages. Therefore all the Android API features are concerned by the API improvement.<\/p>\n<p><strong>Methods becoming obsolete<\/strong><\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/Android15.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1491\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/Android15.png\" alt=\"Android15\" width=\"420\" height=\"496\" \/><\/a><\/p>\n<p>Only few methods become obsolete. It&#8217;s interesting to know them and avoid their use when using the new major API version.<\/p>\n<p><strong>Visibility changes for methods<\/strong>:<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/Android71.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1470\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/Android71.png\" alt=\"Android7\" width=\"445\" height=\"501\" \/><\/a><\/p>\n<p>Some methods become private to enforce the encapsulation, others become public to let them accessible to apps developers, and some others become protected to make them visible to child classes.<\/p>\n<p><strong>Summary<\/strong><\/p>\n<p>The new major version contains many new interesting features, many packages, classes, methods and fields were added. Thanks to google many new features are added in each new major version. The android developers will benefit from\u00a0all these improvements which help them to produce amazing games and utilities to the end users.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>According to IDC\u00a0\u00a0Android is the most popular mobile operating system in the world. Nothing new there, for many years android was the leader. But, what&#8217;s amazing is the growth percent between 2011 and 2014.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-1451","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=\/wp\/v2\/posts\/1451","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1451"}],"version-history":[{"count":27,"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=\/wp\/v2\/posts\/1451\/revisions"}],"predecessor-version":[{"id":1503,"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=\/wp\/v2\/posts\/1451\/revisions\/1503"}],"wp:attachment":[{"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1451"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}