A look at some of the new Android M developer APIs, for people who aren't developers.
There will be plenty of changes and new features "under the hood" in Android M, the as-yet-unnamed next major version of Android, which will be released later this year. We all love new features that we can see. But often the best — and most important — changes are deep down in the core, quietly doing their thing and making stuff better. These new and improved bits of code are what Google and third-party developers use to make magic happen.
We're getting a taste of what's to come now in the M Developer Preview. Some of us (guilty) get all gooey inside when we talk about new APIs and the powerful things developers can do with them. More of us probably would get gushing if these APIs were presented in easy-to-read-not-codemonkey-nerd dialect, and instead broken down in plain language without all the talk about classes, methods and services.
We brought out the Geek-to-English translator and we're going to have a look at the new Android M APIs, and talk about what they can do. Strap in.
What is an API?
This is the best place to start. We're going to talk about a handful of new APIs, so everyone needs to know what those three letters mean.
An API is a shortcut and a gatekeeper, and makes life easier on everyone.
API is an acronym for Application Programming Interface. Think of them as a sort of plugin that the folks who wrote the Android code have provided, and developers can use to communicate with the system and do "stuff" without writing out a bajillion lines of code themselves. APIs also allow developers to communicate with areas of Android that are protected, so the system can return information that would be otherwise unobtainable. So APIs are shortcuts as well as gatekeepers.
A developer writing an app for Android simply has to include the right classes, methods and services for the feature they want to implement, and all the heavy lifting is done elsewhere in the operating system. For example, take this bit of code to enable the new Direct Share API:
<activity android:name=".MyShareActivity" android:label="@string/share_activity_label"> <intent-filter> <action android:name="android.intent.action.SEND" /> </intent-filter> <meta-data android:name="android.service.chooser.chooser_target_service" android:value=".ChooserTargetService" /> </activity>
That is far easier than writing out all the code for one app to authenticate and define the targets for a particular intent so that their the correct app opens when you want to share something in a certain way, with a certain person. (See? Even explaining that isn't fun.)
Think of an API as a shortcut, where most of the work was done by Google, that developers can include in their code to use Android's features in their apps. This makes them powerful tools and makes for better apps.
Now that you have an idea of what an API is, let's have a look at an overview of the new APIs in Android M.