Google announced new Android Version Android O on 21st Mar 2017, Tuesday. Android O is First Developer Preview. Google has introduced new features in this version and also increases security for the user. There are many new things has been introduced by google which is very easy to adapt for an android app developer. Google announce that the full version will be released at the end of 2017. For download, this version check this link: Check.

In Android, O Version google focused on security and modification in main features of the os and last but not least renovating the UI. In this preview, a developer can focus on what main amendment in Android O and consuming them dev can modify their current app and also develop a new app using google developer guidelines and the new APIs.

What’s New in Android O: Let’s find out.

Notification Channel:
In this version, if your app target Android O you have to implement Notification Channel for showing notifications for your app. This new feature is mainly used for divide notification in categories for single App and a user can control that like Block, Change Priority, Vibrations Mode, lights, change lock screen privacy. If your app is chatting one than the app will send notification for a single contact or for a group and also notification for a separate group. These notification channels give you more fine-grained control of notification, the developer has more flexibility to send different types of notifications with less risk of completed block.

Background Execution limits:
From Nougat, background limits are introduced but it is only for certain activity it prevents three implicit broadcasts such as new photo broadcast from manifest declared receivers. In Android O targeting app, this builds in beginning and its mandatorily for saving power and better battery life.

This version will no receiver implicit broadcasts from manifest declared except BOOT_Complted, Locale Change, USB device attached. You can implicit broadcast at runtime when the app is active.
Explicit Broadcast will unchanged and still be delivered from manifest declaration using package name.

Background services only run for a small time when the app is in visible state or foreground service. Method startService() or pendingIntent throws illegalStateException so it is depreciated.
Foreground Service is unchanged and works as usual. There is a new API to start a foreground service directly by
NoticationManger#startServiceForeground that takes notification and ID.

For Not Targeting Android O:
1.The app in cache states Wake Locks will be released.
2.Background location updates change, app will only get limited updates (few times per hour)
3.Foreground Location is independent so it is unchanged, you can also access the location updates from any other app which is in the foreground with the same frequency in the background.

Picture-in-Picture Mode:
It is now available for all devices not for only Android TV. You have to do is to call enter picture in picture mode method from pause or resume state where the system supports entering PIP. It is like the multi-window the activity gets into paused state in PIP mode. For media app, you should handle onPause for continue playback as well.

AutoFill Framework:
In this version this new Autofill API, the filling form is time-consuming so google is launching auto fill in the app like google chrome browser that makes it easy for apps to help their users through this. It’s like similar to way keyboard app allows selecting an autofill app. Autofill is for storing and securing user data, such as address, credit card info, password, name, birthdate etc.

Adaptive Icon:
In Android O adaptive launcher icons is introduced which display differently with different device and size. For OEM device launcher icon can be the circular shape and you can define it in the manifest file.New Adaptive icon is also used in shortcuts, setting app, sharing dialog and overview screen.
In Manifest you can define like:

<application

android:icon=”
@mipmap/ic_launcher
android:roundIcon=”
@mipmap/ic_launcher_round
…>
</application>

For creating the adaptive icon you should use <maskable-icon> and create two layers one for background and one for foreground like:

<maskable-icon>
<background android:drawable=”
@color/ic_background”/>
<foreground android:drawable=”
@mipmap/ic_foreground”/>
</maskable-icon>

Fonts:
Android O introduces a new feature for fonts which is very hectic previously by getAssest(). Now the developer can use fonts in XML like resources type. Create a new directory under res folder and put all fonts file and access them directly from R file. To set the font in TextView use like this:
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:fontFamily=”
@font/fontName”/>

Pinning shortcuts and widgets:
Pinned shortcuts are likely are shortcuts, it allows the user to start a specific task in your app. You have to create a different icon for a different task.
On Android O device, the launchers allow creating widgets for a specific task like pinned shortcuts.

MultiDisplay Support:
In Android O, multiple displays are more supported and enhanced in this update. If an app supports multi-windows running on a multi-device, the user can move activity from one to another device.For default, an app will decide which display should run activity.

Autosize TextView:
In this version, auto size is support and let set size for expanding or contract automatically based on the size of View.For achieving this feature you should use one of this methods.

1. Granularity:
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:autoSizeText=”uniform” //Resize vertical and horizontal
android:autoSizeMinTextSize=”12sp”
android:autoSizeMaxTextSize=”100sp”
android:autoSizeStepGranularity=”2sp”
/>

2. Preset Size:
Create an array of the preset size of textView and use that in XML attribute:
<resources>
<array
name=”autosize_text_sizes”>
<item>10sp</item>
<item>12sp</item>
<item>20sp</item>
<item>40sp</item>
<item>100sp</item>
</array>
</resources>

<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:autoSizeText=”uniform”
android:autoSizePresetSizes=”
@array/autosize_text_sizes
/>

Wifi Aware:
Android O latest features introduce Wi-Fi Aware. Which is based on the Neighbor Awareness Networking (NAN) specification?With this feature, the nearby device can discover and communicate without using the internet.

Account Access:
The app which is targeting Android O won’t be able to get access to user accounts using Get_ACCOUNTS Permission alone. For accessing account you should create an intent for a choosing account. This means Account owners can now choose whether the account will be visible to apps.

Miscellaneous:
Android O introduces several features and modification in UI. Like WebView Enhancements, Audio API, Pro Audio, Device Id for per user per app.For Android, Wear developer can test Android O in the emulator. System Image of Android O Nexus 5X/6P, Nexus Player, and Pixel/C/XL devices.
In Android O key focus of google is to engage the user for more time and improve battery life. The developer should adapt new feature to improve user engagement and improve your app performance.

--

--

Harsh Mittal

Android Developer, Freelance, Enthusiastic Learner