Aug 14

Google releases source for Google I/O 2018 for Android


Posted by Shailen Tuli, DPE

Today we’re releasing the source code for the official Google I/O 2018 for Android app.

The 2018 version constitutes a comprehensive rewrite of the app. For many years, the app has used a ContentProvider + SyncAdapter architecture. This year, we rewrote the app using Architecture Components and brought the code in sync with the Android team’s current recommendations for building modern apps.

Architecture

We followed the recommendations laid out in the Guide to App Architecture for writing modular, testable and maintainable code when deciding on the architecture for the app. We kept logic away from Activities and Fragments and moved it to ViewModels. We observed data using LiveData and used the Data Binding Library to bind UI components in layouts to the app’s data sources.

The overall architecture of the app can be summarized in this diagram:

We used a Repository layer for handling data operations. IOSched’s data comes from a few different sources — user data is stored in Cloud Firestore (either remotely or in a local cache for offline use), user preferences and settings are stored in SharedPreferences, conference data is stored remotely and is fetched and stored in memory for the app to use — and the repository modules are responsible for handling all data operations and abstracting the data sources from the rest of the app. If we ever wanted to swap out the Firestore backend for a different data source in the future, our architecture allows us to do so in a clean way.

We implemented a lightweight domain layer, which sits between the data layer and the presentation layer, and handles discrete pieces of business logic off the UI thread. Examples.

We used Dagger2 for dependency injection and we heavily relied on dagger-android to abstract away boilerplate code.

We used Espresso for basic instrumentation tests and JUnit and Mockito for unit testing.

Firebase

The use of Firebase technologies has grown in the app as the Firebase platform has matured. The 2018 version uses the following Firebase components:

  • Cloud Firestore is our source for all user data (events starred or reserved by a user). Firestore gave us automatic sync and also seamlessly managed offline functionality for us.
  • Firebase Cloud Functions allowed us to run backend code. The reservations feature heavily depended on Functions checking a user’s status (only attendees were allowed to make reservations), checking space availability and persisting reservation status in Firestore.
  • Firebase Cloud Messaging let us inform the app about changes to conference data on our server. Conference data is mostly static, but it does change from time to time, especially after the keynote. The app has traditionally used a ping-and-fetch model when working with conference data, and we retained that usage this year.
  • Remote Config helped us manage in-app constants. In previous years, we had found ourselves unable to inform users when data not directly related to the conference schedule — WiFi information, conference shuttle schedule, etc. — changed unexpectedly. Remote Config helped us update such values in a lightweight manner.

Kotlin

We made an early decision to rewrite the app from scratch to bring it in line with modern Android architecture. Using Kotlin for the rewrite was an easy choice: we loved Kotlin’s expressive, concise, and powerful syntax; we found that Kotlin’s support for safety features including nullability and immutability made our code more resilient; and we leveraged the enhanced functionality provided by Android Ktx extensions.

Material Design

At I/O 2018, the Material Design team announced Material Theming, giving apps much greater ability to customize Material Design to bring more of their product’s brand. As we launched the app before Material Theming, we couldn’t use all of the new components but we managed to sneak a couple in like the new Bottom App Bar with inset Floating Action Button and we were able to incorporate a lot of the conference’s branding elements.

Future plans

The rewrite of the app brings the code in sync with Android’s opinionated recommendations about building apps, and it resulted in a cleaner, more maintainable codebase. We’ll continue working on the app, incorporating JetPack components as they become available and finding opportunities to showcase platform features that are good fits for the app. Developers can follow changes to the code on GitHub.


Android Developers Blog

Aug 09

Watch sessions from the Playtime 2016 events to learn how to succeed on Android & Google Play

Posted by Patricia Correa, Head of Developer Marketing, Google Play

We’re wrapping up our annual global Playtime series of events with a last stop in Tokyo, Japan. This year Google Play hosted events in 10 cities: London, Paris, Berlin, Hong Kong, Singapore, Gurgaon, San Francisco, Sao Paulo, Seoul and Tokyo. We met with app and game developers from around the world to discuss how to build successful businesses on Google Play, share experiences, give feedback, collaborate, and get inspired.

You can now watch some of the best Playtime sessions on our Android Developers YouTube Channel, as listed below. The playlist opens with a video that celebrates collaboration.


Keynote

What’s next for Google Play

Learn how we’re helping users discover apps in the right context, creating new
ways to engage with users beyond the install, and powering innovative
experiences on emerging platforms like virtual reality, wearables, and auto.

Develop and launch apps & games

Android
development in 2016

Android development is more powerful and efficient than ever before. Android
Studio brings you speed, smarts, and support for Android Nougat. The broad range
of cross-platform tools on Firecase can improve your app on Android and beyond.
Material Design and Vulkan continue to improve the user experience and increase
engagement.

Daydream
& Tango

Daydream View is a VR headset and controller by Google that lets people explore
new worlds, or play games that put them at the center of action. Learn how we’re
helping users discover apps in the right context and powering new experiences
with Daydream and Tango.

Fireside
chat – Wayfair & Pokémon GO on augmented reality

Augmented reality engages and delights people everywhere. In this fireside chat,
online furniture seller Wayfair and Niantic’s Pokémon
GO share their experiences with AR and discuss how other developers can make
the most of the platform.

Building
for billions, featuring best practices from Maliyo Games

Learn how to create apps and games for emerging markets, which are expected to
drive 80% of global smartphone growth by 2020, by recognizing the key challenges
and designing the right app experiences to overcome them.

At minute 16:41, hear tips from Hugo Obi, co-founder of Nigerian games developer
Maliyo.

Launch
smart on Google Play

Set your app up for success using experimentation and iteration. Learn best
practices for soft launching and adapting your app for different markets and
device types.

Apps

Sustainable
growth solves most problems for apps, featuring best practices from
SoundCloud &
Peak

Planning and executing a great growth strategy involves a complex set of choices
and mastery of many tools. In this session we discuss topics including key
business objectives, tools, and techniques to help you solve the growth puzzle
with our partner, SoundCloud.

Also, check out some growth
best practices from Peak.

Creating
sustainable user growth for startups, by Greylock

User growth isn’t just about growing the number of users you have. The key to
sustainability is creating and delivering core product value. In this session,
VC Greylock discusses how to identify your core action to focus on and shows you
how to use these insights to optimize your app for long term growth.

App
engagement is the new black, featuring best practices from Lifesum

As the app marketplace becomes more competitive, developer success depends on
retaining users in apps they love. Find out which Google tools and features can
help you analyze your users’ behaviors, improve engagement and retention in your
app and hear insights from others developers including Lifesum.

Predicting
lifetime value in the apps world

Deepdive into lifetime value models and predictive analytics in the apps ecosystem.
Tactics to get the most out of identified segments and how to upgrade their
behaviors to minimize churn.

Subscriptions
update

Learn about Google’s efforts to enable users, around the world, to seamlessly
and safely pay for content. This session provides updates on Google Play billing
and recent enhancements to our subscriptions platform.

Games

One
game fits all, featuring best practices from Space Ape Games

Customize your game’s experience for different users by targeting them with lifetime value
models and predictive analytics. Hear how these concepts are applied by
Space Ape Games to improve retention and monetization of their titles.

Promoting
your game and growing your user base, featuring best practices from Seriously

Learn how to use Google’s latest tools, like Firebase, for benchmarking,
acquiring users and measuring your activities. Also, hear game
developer Seriously share their latest insights and strategies on YouTube
influencer campaigns.

Creating
long-term retention, loyalty and value with engaging LiveOps events, featuring
best practices from Kabam &
Creative Mobile

Learn how successful developers keep their games fresh and engaging with Live
Operations. In this talk, the LiveOps expert on Marvel: Contest of Champions
discusses tips about the art and science of running an engaging LiveOps event.

Also check out the tips and best
practices to run successful LiveOps from games developer Creative Mobile.

Panel
- Play fair: Maintaining a level playing field in your game, featuring Space Ape
Games and Kongregate

Ensuring that your game is fair is critical to success. Find out how game
developers are achieving this and some ways Google Play can help.

Families

Why
you need to build for families

Family-based households with children have higher tablet and smartphone
ownership rates than the general population. These families are more likely to
make purchases on their mobile devices and play games. Learn about how parents
choose what to download and buy, and how you can prepare for maximum conversion.

Two
keys to growth: user acquisition & app engagement, by Cartoon Network

Hear how Cartoon Network leverages their network to cross-promote new titles,
acquire new users and keep them engaged through immersive experiences.

Go
global: Getting ready for the emerging markets revolution, by
Papumba

Papumba has a clear vision to grow a global business. Hear how they work with
experts to adapt their games to local markets and leverage Google Play’s
developer tools to find success around the world.

Optimizing
for a post install world

You’ve spent time and resources getting users to download your apps, but what
happens after the install? Learn how to minimize churn and keep families engaged
with your content long term.

Monetization
best practices on freemium, by 01 Digital

Learn how 01 Digital uses In-App-Purchases (IAP) to effectively monetize their
apps while maintaining a safe environment for families.

Building
a subscription business that appeals to parents, by PlayKids

PlayKids has been at the forefront of the subscription business model since
their inception. See how they best serve their subscribers by refreshing their
content, expanding their offerings and investing in new verticals.




How useful did you find this blogpost?


Android Developers Blog

Aug 09

Looking forward with Google Play

Posted by Purnima Kochikar, Director, Google Play, Apps & Games

On Monday we released Android 9 Pie. As we continue to push the Android platform forward, we’re always looking to provide new ways to distribute your apps efficiently, help people discover and engage with your work, and improve the overall security of our ecosystem. Google Play has had a busy year so far with some big milestones around helping you reach more users, including:

  • Shrinking download size: Android App Bundle & Dynamic Delivery has helped reduce app sizes by up to 65%, leading to increased downloads and fewer uninstalls.
  • Helpling improve quality: New tools in the Play Console have helped you reduce crash rates by up to 70%.
  • Improving discovery: Improvements to the discovery experience has increased Google Play Store visits by 30% over the last 12 months.
  • Keeping users safe: Google Play Protect scans more than 50 billion apps a day and Android API level 26 adoption requirements improve app security and performance.

Google Play is dedicated to helping you build and grow quality app businesses, reach the more than 2 billion Android devices globally and provide your users with better experiences. Here are some of the important areas we’re prioritizing this year:

Innovative Distribution

We’ve added more testing tools to the popular Play Console to help developers de-risk app launches with internal and external test tracks and staged rollouts to get valuable early feedback. This year we’ve expanded the Start on Android program globally that provides developers new to Android additional guidance to optimize their apps before launch. Google Play Instant remains a huge bet to transform app discovery and improve conversions by letting users engage without the friction of installing. We’re seeing great results from early adopters and are working on new places to surface instant experience, including ads, and making them easier to build throughout the year.

Improving App Quality

Google Play plays an important role helping developers understand and fix quality and performance issues. At I/O, we showcased how we expanded the battery, stability and rendering of Android vitals reporting to include app start time & permission denials, enabling developers to cut application not responding errors by up to 95%. We also expanded the functionality of automated device testing with the pre-launch report to enable games testing. Recently, we increased the importance of app quality in our search and discovery recommendations that has resulted in higher engagement and satisfaction with downloaded games.

Richer Discovery

Over the last year we’ve rolled out more editorial content and improved our machine learning to deliver personalized recommendations for apps and games that engage users. Since most game downloads come from browsing (as opposed to searching or deep linking into) the store, we’ve put particular focus on games discovery, with a new games home page, special sections for premium and new games, immersive video trailers and screenshots, and the ability to try games instantly. We’ve also introduced new programs to help drive app downloads through richer discovery. For example, since launching our app pre-registration program in 2016, we’ve seen nearly 250 million app pre-registrations. Going forward, we’ll be expanding on these programs and others like LiveOps cards to help developers engage more deeply with their audience.

Expanding Commerce Platform

Google Play now collects payments in 150 markets via credit card, direct carrier billing (DCB), Paypal, and gift cards. Direct carrier billing is now enabled across 167 carriers in 64 markets. In 2018, we have focused on expanding our footprint in Africa and Latam with launches in Ghana, Kenya, Tanzania, Nigeria, Peru & Colombia. And users can now buy Google Play credit via gift cards or other means in more 800,000 retail locations around the world. This year, we also launched seller support in 18 new markets bringing the total markets with seller support to 98. Our subscription offering continues to improve with ML-powered fraud detection and even more control for subscribers and developers. Google Play’s risk modeling automatically helps detect fraudulent transactions and purchase APIs help you better analyze your refund data to identify suspicious activity.

Maintaining a Safe & Secure Ecosystem

Google Play Protect and our other systems scan and analyze more than 50 billion apps a day to keep our ecosystem safe for users and developers. In fact, people who only download apps from Google Play are nine times less likely to download a potentially harmful app than those who download from other sources. We’ve made significant improvements in our ability to detect abuse—such as impersonation, inappropriate content, fraud, or malware—through new machine learning models and techniques. The result is that 99% of apps with abusive content are identified and rejected before anyone can install them. We’re also continuing to run the Google Play Security Rewards Program through a collaboration with Hacker One to discover other vulnerabilities.

We are continually inspired by what developers build—check out #IMakeApps for incredible examples—and want every developer to have the tools needed to succeed. We can’t wait to see what you do next!


Android Developers Blog

Aug 09

Google I/O 2014 App Source Code Now Available


By Bruno Oliveira, Tech Lead of the I/O app project

The source code for the 2014 version of the Google I/O app is now available. Since its first release on Google Play a few weeks before the conference, the I/O app was downloaded by hundreds of thousands of people, including on-site attendees, I/O Extended event participants and users tuning in from home. If one of the goals of the app is to be useful to conference attendees, the other primary goal is to serve as a practical example of best practices for Android app design and development.

In addition to showing how to implement a wide variety of features that are useful for most Android apps, such as Fragments, Loaders, Services, Broadcast Receivers, alarms, notifications, SQLite databases, Content Providers, Action Bar and the Navigation Drawer, the I/O app source code also shows how to integrate with several Google products and services, from the Google Drive API to Google Cloud Messaging. It uses the material design approach, the Android L Preview APIs and full Android Wear integration with a packaged wearable app for sending session feedback.

To simplify the process of reusing and customizing the source code to build apps for other conferences, we rewrote the entire sync adapter to work with plain JSON files instead of requiring a server with a specific API. These files can be hosted on any web server of the developer’s choice, and their format is fully documented.

Storing and syncing the user’s data (that is, the personalized schedule) is crucial part of the app. The source code shows how user data can be stored in the Application Data folder of the user’s own Google Drive account and kept in sync across multiple devices, and how to use Google Cloud Messaging to trigger syncs when necessary to ensure the data is always fresh.

The project includes the source code to the App Engine app that can be reused to send GCM messages to devices to trigger syncs, as well as a module (called Updater) that can be adapted to read conference data from other backends to produce the JSON files that are consumed by the I/O app.

We are excited to share this source code with the developer community today, and we hope it will serve as a learning tool, a source of reusable snippets and a useful example of Android app development in general. In the coming weeks we will post a few technical articles with more detailed information about the IOSched source code to help bring some insight into the app development process. We will continue to update the app in the coming months, and as always, your pull requests are very welcome!

Join the discussion on
+Android Developers


Android Developers Blog

Aug 06

Google Play Services 3.2

We’ve just finished rolling out the latest release of Google Play services to devices around the world. It offers better performance and greater power savings, as well as enhancements to the Location Based Services, maps, InstantBuy, Google+, and Photo Sphere.

To simplify your testing, we’ve also released an updated Google APIs emulator image that includes Google Play Services 3.2. You can download the image through the Android SDK Manager.

Maps and Location Based Services

Google Play Services 3.2 includes several enhancements to the Location Based Services. The Fused Location Provider now supports the selection of a low-power mode option when requesting location updates, and the ability to inject mock locations — allowing you to more efficiently test your apps in a variety of simulated conditions.

The geofencing APIs have been updated to support hardware-based GPS geofencing on devices that have supporting hardware, such as the Nexus 4. Hardware geofences consume significantly less battery, and best of all your app will automatically take advantage of this feature on supported hardware without you having to make any changes.

A new Snapshot feature in the maps API lets you capture a bitmap image of the current map in order to improve performance when an interactive map isn’t necessary. We’ve also added a listener to the My Location button.

Google+, Photo Sphere, InstantBuy, and Analytics

If you’ve used Google+ sign-in you can take advantage of the new simplified sharing control that can be embedded directly within your app, simplifying the process of sharing content directly to Google+. We’ve also taken the opportunity to add some butter to the Google+ sign-in animation.

The Photo Sphere viewer has also been extended to include a compass mode that allows users to explore Photo Spheres by moving their phones.

The InstantBuy implementation has been improved to increase efficiency, with improved latency, a cleaner UI with contextual text and assets for the holo light theme, and support for passing through loyalty and offers information.

More About Google Play Services

To learn more about Google Play services and the APIs available to you through it, visit the Google Services area of the Android Developers site.

Join the discussion on

+Android Developers


Android Developers Blog

Aug 03

Barcode Detection in Google Play services

Posted by Laurence Moroney, Developer Advocate

With the release of Google Play services 7.8 we’re excited to announce that we’ve added new Mobile Vision APIs which provides the Barcode Scanner API to read and decode a myriad of different barcode types quickly, easily and locally.

Barcode detection

Classes for detecting and parsing bar codes are available in the com.google.android.gms.vision.barcode namespace. The BarcodeDetector class is the main workhorse — processing Frame objects to return a SparseArray<Barcode> types.

The Barcode type represents a single recognized barcode and its value. In the case of 1D barcode such as UPC codes, this will simply be the number that is encoded in the barcode. This is available in the rawValue property, with the detected encoding type set in the format field.

For 2D barcodes that contain structured data, such as QR codes, the valueFormat field is set to the detected value type, and the corresponding data field is set. So, for example, if the URL type is detected, the constant URL will be loaded into the valueFormat, and the URL property will contain the desired value. Beyond URLs, there are lots of different data types that the QR code can support — check them out in the documentation here.

When using the API, you can read barcodes in any orientation. They don’t always need to be straight on, and oriented upwards!

Importantly, all barcode parsing is done locally, making it really fast, and in some cases, such as PDF-417, all the information you need might be contained within the barcode itself, so you don’t need any further lookups.

You can learn more about using the API by checking out the sample on GitHub. This uses the Mobile Vision APIs along with a Camera preview to detect both faces and barcodes in the same image.

Supported Bar Code Types

The API supports both 1D and 2D bar codes, in a number of sub formats.

For 1D Bar Codes, these are:

AN-13

EAN-8

UPC-A

UPC-E

Code-39

Code-93

Code-128

ITF

Codabar

For 2D Bar Codes, these are:

QR Code

Data Matrix

PDF 417

Learn More

It’s easy to build applications that use bar code detection using the Barcode Scanner API, and we’ve provided lots of great resources that will allow you to do so. Check them out here:

Follow the Code Lab

Read the Mobile Vision Documentation

Explore the sample

Join the discussion on

+Android Developers


Android Developers Blog

Aug 02

Grow with Google Play: Scaled Publishing and New App Insights

By Kobi Glick, Google Play team

If you’re growing your business on Google Play, the Google Play Developer Console is one of the most important tools at your disposal. At Google I/O, we introduced a number of new changes that give you valuable insight into how your app is performing. Here’s an overview of some of the improvements you can now take advantage of.

Publishing API for scaling your app operations

Today we’re happy to announce that the Google Play Developer Publishing API is now available to all developers. The API will let you upload APKs to Beta testing, Staged rollout and Production, and integrate publishing operations with your release processes and toolchain. The Publishing API also makes it easier for you to manage your in-app products catalog, provide tablet-specific screenshots, and localize your store listing text and graphics. The Publishing API will help you focus on your core business, with less time managing your releases, even as your business grows to more apps and markets.

Actionable insights at the right time

Email notifications for alerts

Recently, we added Alerts in the Developer Console to let you know when there are sudden changes in important stats like app installs, ratings, and crashes. You can now turn on email notifications for Alerts so that, even while you’re not in the Developer Console, you’ll be informed of relevant events before they can have a broader effect on your app. You can turn on email notifications for one or more of your apps under Email Preferences in the Developer Console settings.

New Optimization Tips

You’ll now see new Optimization Tips with instructions when we detect opportunities to improve your app. For example, we’ll let you know when updated versions of APIs you use are available — such as new Google Play in-app billing or Google Maps APIs. For games developers, we’ll also surface opportunities to use Google Play game services that can help improve users’ gaming experience and drive engagement. To see what tips we suggest for you, go to your app in the Developer Console and click on Optimization Tips.

Better data to inform your business decisions

Enhanced revenue statistics

To help you better understand your commercial success, we’ve enhanced revenue statistics in the Finance section of the Developer Console. We now let you see the average revenue per paying user (ARPPU) and give you more ways to analyse buyer data, such as comparing returning buyers (i.e., those who also made purchases in the past) to new buyers.

Bulk export of reviews

You can already engage with your users by reading and replying to reviews in the Developer Console and we’ve now added bulk export of reviews so you can download and analyze your app’s reviews en masse. This is particularly useful if you receive a large volume of reviews and want to perform your own sentiment analysis.

Improved stats for beta releases and staged rollouts

Since last year’s launch, you’ve used beta testing to release alpha and beta versions of your app, and staged rollout to gradually launch your app to production. To help you make the most of this feature, we’re now improving the way alpha, beta and staged rollout specific stats are displayed. When viewing your app and crash statistics you can now filter the app version by alpha, beta, or staged rollout to better understand the impact of your testing.

Improved reporting of native crashes

If you develop in native code, we’ve improved the reporting and presentation specifically for native crashes, with better grouping of similar crashes and summarizing of relevant information.

Deep-linking to help drive engagement

Finally, we’ve also added website verification in the Developer Console, to enable deep-linking to your app from search results. Deep-linking helps remind users about the apps they already have. It is available through search for all apps that implement app indexing. For example, if a user with the Walmart Android app searches for “Chromecast where to buy”, they’ll go directly to the Chromecast page in the Walmart app. The new App Indexing API is now open to all Android developers, globally. Get started now.

We hope you find these features useful and take advantage of them so that you can continue to grow your user base and improve your users’ experience. If you’re interested in some other great tools for distributing your apps, check out this blog post, or any of the sessions which have now been posted to the Google Developers Channel.

Join the discussion on
+Android Developers


Android Developers Blog

Aug 02

Android Developer Story: Zabob Studio and Buff Studio reach global users with Google Play

Posted by Lily Sheringham, Google Play team

South Korean Games developers Zabob Studio and Buff Studio are start-ups seeking to become major players in the global mobile games industry.

Established in 2013, Zabob Studio was set up by Kwon Dae-hyeon and his wife in 2013. This couple-run business but they have already published ten games, including hits ‘Zombie Judgement Day’ and ‘Infinity Dungeon.’ So far, the company has generated more than KRW ₩140M (approximately $ 125,000 USD) in sales revenue, with about 60 percent of the studio’s downloads coming from international markets, such as Taiwan and Brazil.

Elsewhere, Buff Studio was founded in 2014 and right from the start, its first game Buff Knight was an instant hit. It was even featured as the ‘Game of the Week’ on Google Play and was included in “30 Best Games of 2014” lists. A sequel is already in the works showing the potential of the franchise.

In this video, Kwon Dae-hyeon, CEO of Zabob Studio ,and Kim Do-Hyeong, CEO of Buff Studio, talk about how Google Play services and the Google Play Developer Console have helped them maintain a competitive edge, market their games efficiently to global users and grow revenue on the platform.

Android Developer Story: Buff Studio – Reaching global users with Google Play

Android Developer Story: Zabob Studio – Growing revenue with Google Play

Check Zabob Studio apps and Buff Knight on Google Play!

We’re pleased to share that Android Developer Stories will now come with translated subtitles on YouTube in popular languages around the world. Find out how to turn on YouTube captions. To read locally translated blog posts, visit the Google developer blog in Korean.

Join the discussion on

+Android Developers


Android Developers Blog

Aug 01

Indie game developers in Latin America sustain growth after launch on Google Play

Posted by Kacey Fahey, Marketing Programs Manager, Google Play

Indie game developers are some of the most exciting and innovative teams to work
with. While developers large and small exist on the same field, gone are the
days where you hit publish and turn your back, moving on to the next project. We’ve
gathered a few developer stories coming out of Latin America sharing experiences
and advice.

Oktagon Games

Ronaldo Cruz, Founder and CEO of Oktagon
Games tells us how “reviews provide great qualitative insight on the
game helping us identify problems that may not be caught by analytics.”


Tiny Bytes

Tiny
Bytes reduced churn by 5% using an in-game tutorial and analytics.

Impossible Apps

Cleverson Schmidt of Impossible
Apps shares how introducing in-app purchases helps diversify revenue streams
and “can make the game profitable and self sustainable.”


How useful did you find this blogpost?


Android Developers Blog

Jul 30

Face Detection in Google Play services

Posted by Laurence Moroney, Developer Advocate

With the release of Google Play services 7.8, we announced the addition of new Mobile Vision APIs, which includes a new Face API that finds human faces in images and video better and faster than before. This API is also smarter at distinguishing faces at different orientations and with different facial features facial expressions.

Face Detection

Face Detection is a leap forward from the previous Android FaceDetector.Face API. It’s designed to better detect human faces in images and video for easier editing. It’s smart enough to detect faces even at different orientations — so if your subject’s head is turned sideways, it can detect it. Specific landmarks can also be detected on faces, such as the eyes, the nose, and the edges of the lips.

Important Note

This is not a face recognition API. Instead, the new API simply detects areas in the image or video that are human faces. It also infers from changes in the position frame to frame that faces in consecutive frames of video are the same face. If a face leaves the field of view, and re-enters, it isn’t recognized as a previously detected face.


Detecting a face

When the API detects a human face, it is returned as a Face object. The Face object provides the spatial data for the face so you can, for example, draw bounding rectangles around a face, or, if you use landmarks on the face, you can add features to the face in the correct place, such as giving a person a new hat.

  • getPosition() – Returns the top left coordinates of the area where a face was detected
  • getWidth() – Returns the width of the area where a face was detected
  • getHeight() – Returns the height of the area where a face was detected
  • getId() – Returns an ID that the system associated with a detected face

Orientation

The Face API is smart enough to detect faces in multiple orientations. As the head is a solid object that is capable of moving and rotating around multiple axes, the view of a face in an image can vary wildly.

Here’s an example of a human face, instantly recognizable to a human, despite being oriented in greatly different ways:

The API is capable of detecting this as a face, even in the circumstances where as much as half of the facial data is missing, and the face is oriented at an angle, such as in the corners of the above image.

Here are the method calls available to a face object:

  • getEulerY() – Returns the rotation of the face around the vertical axis — i.e. has the neck turned so that the face is looking left or right [The y degree in the above image]
  • getEulerZ() – Returns the rotation of the face around the Z azis — i.e. has the user tilted their neck to cock the head sideways [The r degree in the above image]

Landmarks

A landmark is a point of interest within a face. The API provides a getLandmarks() method which returns a List , where a Landmark object returns the coordinates of the landmark, where a landmark is one of the following: Bottom of mouth, left cheek, left ear, left ear tip, left eye, left mouth, base of nose, right cheek, right ear, right ear tip, right eye or right mouth.

Activity

In addition to detecting the landmark, the API offers the following function calls to allow you to smartly detect various facial states:

  • getIsLeftEyeOpenProbability() – Returns a value between 0 and 1, giving probability that the left eye is open
  • getIsRighteyeOpenProbability() – Same but for right eye
  • getIsSmilingProbability() – Returns a value between 0 and 1 giving a probability that the face is smiling

Thus, for example, you could write an app that only takes a photo when all of the subjects in the image are smiling.

Learn More

It’s easy to build applications that use facial detection using the Face API, and we’ve provided lots of great resources that will allow you to do so. Check them out here:

Follow the Code Lab

Read the Documentation

Explore the sample


Android Developers Blog