Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Android 8.0 Oreo: Features and Updates You Need to Know

DZone's Guide to

Android 8.0 Oreo: Features and Updates You Need to Know

Check out the new features of Android Oreo to make sure you're designing your Android apps for the best user experience.

· Mobile Zone
Free Resource

Download this comprehensive Mobile Testing Reference Guide to help prioritize which mobile devices and OSs to test against, brought to you in partnership with Sauce Labs.

Android 8.0 Oreo is now OFFICIAL!! It is said to be faster and more powerful than ever. Let's take a look at the new features and enhancements in Android 8.0.

Power Saving and Quicker Boot Time

Oreo has put limits on app background activities, which will increase users' battery life and performance. These limits will include location updates, implicit broadcasts, and background services. This will minimize energy consumption, and in turn, give longer battery life.

If multiple apps are running along with background services, more load is placed on the system, which results in delay and poor user experience. To avoid this problem, Oreo has put restrictions on background work.

There are two types of limitations:

1. Background service limitations

2. Broadcast limitations

If multiple apps registered for many broadcasts, an event that triggers a broadcast causes all those apps to receive and consume resources, which results in poor user experience. Apps that target Android 8.0 or higher can no longer register broadcast receivers for implicit broadcasts in their manifest. However, the manifest can be used to register explicit broadcasts.

This means if an app is launched from an implicit broadcast or is launching services in the background, then these implementations will break in Oreo. That is if any app calls startservice() when that app is not foreground, then Illegalstateexception will be thrown. These restrictions only apply to apps that target Android 8.0 (API level 26) or higher, but even in apps targeting less than 26, a user with Oreo can enable most of these restrictions for any app from the settings screen.

However, there are a few services which are whitelisted and treated as foreground even if they are running in the background: when are being triggered from a high priority FCM/GCM notification, performing SMS/MMS delivery, acted from notification action, etc. The same concept goes for implicit broadcasts. A few implicit broadcasts are still allowed, e.g. BOOT_COMPLETED or LOCALE_CHANGED.

For a detailed explanation, you can refer to the Google Developer Blog.

Picture-in-Picture

Another awesome feature of Android Oreo is Picture-in-Picture (PiP). This allows the user to watch videos on a small screen while other apps occupy the full screen, and the user can perform operations. The best example will be the user getting directions on the map along with a video call. Multitasking is now possible with this feature. This is one of the biggest and most awesome features offered in Android, but there is a rule which we need to understand before we jump in and use it. In order to use this, video apps must be updated. For Youtube, a user has to subscribe to YouTube Red or Google Play Music to use the new PiP mode.

Image title

Notifications

This feature provides the user with detailed control over notifications. The user now can disable them entirely or fine-tune them according to his wishes. Major changes are listed below:

  1. Handling notification shade with extra actions: With O, the media control background color changes according to album artwork. With the partial swipe, a user can see options to snooze notifications for a specific time. This swipe also provides access to notification settings for that specific app.

  2. Notification dots: The user can press on dots to see what's new and can clear them by swiping them away. A long press shows contextual menu actions.

  3. Notification channels: This system helps the user manage notifications. If there are too many notifications, a user might completely block notifications. In order to avoid this, Oreo comes with the notification channel concept. Apps targeting Android O or later must implement one or more notification channels to be displayed to users. Each channel is for a different type and can be set the way the app wants to alter the device.

Image title

Autofill

Who wants to keep typing all their details? Android O makes it easy for the user by allowing the OS to autofill information across apps and websites.

Wi-Fi Awareness

In Android O, a new feature called Wi-Fi Awareness will allow Wi-Fi devices to talk to each other via an ad hoc local network.

Emojis

Express yourself with all new round emojis in Android 8.0. Say goodbye to blob emojis.

Adaptive Icons

Oreo allows the user to choose between shapes for icons like a square, round, rounded square, etc. Developers will be able to use different shape app icons, according to the manufacturer's preference. Google introduced strict guidelines to adhere to icon design that will help to create a unified visual style across more apps.

Google Play Protect

This lets users know whether the app about to install has been certified safe by the Google Play team. Play Protect scans billions of apps in the Play Store to ensure apps won't damage your device.

Autosizing TextViews

Oreo allows TextView to expand or contract automatically to fill its layout based on characteristics and boundaries. That is, if TextView has only a few words to display in a large area, it may scale your text up to avoid awkward empty space in the layout, whereas if TextView has a large amount of text, it will scale that text down rather than cut it off mid-sentence.

Image title

There are three ways you can set up the auto sizing of TextView:

Default: Lets the auto sizing of TextView scale uniformly on horizontal and vertical axes.

android:autoSizeTextType = "uniform" [ or none].

Granularity: We can define the biggest, smallest, and scaling increment:

android:autoSizeTextType = "uniform" android:autoSizeMinTextSize = "12sp"

android:autoSizeMaxTextSize = "100sp" android:autoSizeStepGranularity = "2sp"

Preset Sizes: Lets users specify all the values that the TextView picks when automatically auto-sizing text. We can create an array of sizes and TextView will select the most appropriate size from the available values:

android:autoSizeTextType = "uniform"

android:autoSizePresetSizes = "@array/autosize_text_sizes"

<resources>
<array name=“autosize_text_sizes”>
<item>10sp</item>
<item>12sp</item>
<item>20sp</item>
<item>40sp</item>
<item>100sp</item>
</array>
</resources>

Fonts

Custom fonts are now a fully supported resource type in Oreo. There are two ways we can add custom fonts to app.

  1. Import fonts [ .ttf ] file into project.
  2. Add code that will request chosen font from "Font Provider."

If we go for the 2nd option, then once the app is installed on the device, it will request that specific custom font from "font provider" which will, in turn, fetch the necessary files and caches locally. Happy, right? This means we can use custom fonts without increasing our app APK size.

Oreo also introduced "Fonts in XML." This lets developers use fonts as resources. Add a font file in res/font folder and use it in the XML file. Yay! To add fonts to the TextView or in styles, use the font-family attribute. For example, to access a font resource, use @font/myfont or android:fontFamily = "@font/lobster."

Pinning Shortcuts and Widgets

Oreo introduces in-app pinning of shortcuts and widgets; you can create pinned shortcuts and widgets for supported launchers. Pinned shortcuts appear in supported launchers as separate icons. If you want your app to provide pinned shortcuts, then first verify whether the default launcher supports pinned shortcuts.

In Android 8.0, your app can directly pin a specific app shortcut in the launcher to drive engagement:

Create an instance of ShortcutManager

ShortcutManager myShortcutManager = getSystemService(ShortcutManager.class);
if (myShortcutManager.isRequestPinShortcutSupported()) {


If TRUE, then create shortcutInfo object and add properties.

Define the shortcut’s string ID

ShortcutInfo pinShortcutInfo = ShortcutInfo.Builder(context, “shortcut-Id”);


Set the short label.

 .setShortLabel(getString(R.string.short_label))


Set the long label.

 .setLongLabel(getString(R.string.long_label))


Define the action that you want this shortcut to perform.

 .setIntent(new Intent(Intent.ACTION_DIAL, mostFrequentContact))


Set the icon.

 .setIcon(Icon.createWithResource(context, R.mipmap.ic_contactProfile))   
 .build();


Now pin the shortcut to the user's home screen by implementing  requestPinShortcut() . Once the pin is created, we can update its content by using  updateShortcuts() .


The world is getting smarter, faster and even more powerful with Android 8.0 Oreo. At this time mobile app development companies have opportunities to come up with the applications that can make our work much easier.


Analysts agree that a mix of emulators/simulators and real devices are necessary to optimize your mobile app testing - learn more in this white paper, brought to you in partnership with Sauce Labs.

Topics:
mobile ,android ,android o ,mobile app development

Published at DZone with permission of Divyarani S, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}