Tag Archives: Google Play

“Ok Google, read my book”… Introducing audiobooks on Google Play

"Read more." Every year it’s one of the most popular New Year’s resolutions. But with all the time spent battling traffic, working out, or picking up groceries, there often doesn’t seem to be a minute to simply sit down with a book.


With audiobooks on Google Play, rolling out today in 45 countries and nine languages, you can turn your time stuck in traffic, on the treadmill, or waiting in line into reading time. Find your next great read at an affordable price, and enjoy it across Android, iOS and the web with Google Play Books, as well as on devices that include the Google Assistant, like Google Home and many others. Here’s what you need to know:


  • Listen without a subscription. On Google Play, you can buy a single audiobook at an affordable price, with no commitments. You can also get a free preview of the book to make sure you’re hooked by the story and enjoy listening to the narrator’s voice. And share your favorite audiobook with everyone in the family through Family Library for no additional fee—even if they’re using a different device.
  • Enjoy your audiobook with your Google Assistant.Just say “Ok Google, read my book” to listen to your favorite audiobook hands free with the Google Assistant on your phone or speaker, like Google Home. Try “Ok Google, who is the author?” if you need a refresher, or “Ok Google, stop playing in 20 minutes” to set a timer for bedtime reading. For now, the Google Assistant integration with audiobooks is available on Android phones and smart speakers globally in English. It will be coming soon to the Assistant on Android Auto in the U.S.
xx
  • Weave reading into your day across multiple devices. Start your morning by listening to “Ready Player One” with the Assistant on Google Home, and continue listening with the Google Play Books app on your Pixel. You can pick up where you left off no matter what device you're using, with the Assistant or the Google Play Books app—on Android, iOS, Chromecast, Android Wear, Android Auto or even your laptop. 
Now when you want to solve the mystery with “Magpie Murders,” learn “Astrophysics For People In A Hurry” from Neil Degrasse Tyson or spend a Sunday with Oprah Winfrey, Eckhart Tolle and friends in “The Wisdom of Sundays,” all you have to do is select and settle into the sounds of your new favorite book.

Meet the finalists of the Google Play Indie Games Contest in Europe

Posted by Adriana Puchianu, Developer Marketing Google Play

Back in October we launched the 2nd edition of the Google Play Indie Games Contest in Europe, with the aim to identify, showcase and reward indie gaming talent from more than 30 countries. We were amazed by the innovation and creativity that indie developers from the region have to offer.

Selecting just 20 finalists has once again been a huge challenge. We had a lot of fun playing the games that will go on to showcase at the Saatchi Gallery on February 13th in London. Without further ado, we are happy to announce the Top 20 finalists of this year's edition. Congratulations to the finalists and thanks to everyone else who has entered the contest.

A Planet of Mine
Tuesday Quest
France

Bridge Constructor Portal
ClockStone Softwareentwicklung GmbH
Austria

Bury me, my Love
Playdius
France

Captain Tom Galactic Traveler
Picodongames
France

Core
FURYJAM
Russia

Flat Pack
Nitrome
United Kingdom

Fern Flower
Macaque
Poland

I Love Hue
Zut!
United Kingdom

Jodeo
Gamebra.in
Turkey

Kami 2
State of Play
United Kingdom

Kenshō
FIFTYTWO
Russia

No More Buttons
Tommy Søreide Kjær
Norway

Old Man's Journey
Broken Rules Interactive Media GmbH
Austria

The Big Journey
Catfishbox
Ukraine

The House of Da Vinci
Blue Brain Games, s.r.o.
Slovakia

The Office Quest
11Sheep
Israel

Unbalance
TVEE
Turkey

Undervault
Andriy Bychkovskyi
Ukraine

yellow
Bart Bonte
Belgium

Check out the prizes

All the 20 finalists are getting:

  • A paid trip to London to showcase their game at the Final held at Saatchi Gallery
  • Inclusion of their game on a promotional billboard in London for 1 month
  • Inclusion of their game in a dedicated Indie Games Contest collection on the Indie Corner for one month in more than 40 countries across EMEA
  • Two (2) tickets to attend a 2018 Playtime event, an invitation-only event for top apps and games developers on Google Play
  • One (1) Pixel 2 device

They will also have the chance to win more prizes at the final event.

Join the Google Play team and the finalists at the final event:

Anyone can now register to attend the final showcase event for free at the Saatchi Gallery in London on 13 February 2018. Come and play some great games and have fun with indie developers, industry experts, and the Google Play team.

How useful did you find this blogpost?

Android Excellence: congratulations to the newly added apps and games

Posted by Kacey Fahey, Developer Marketing, Google Play

Kicking off the new year, we're excited to welcome our latest group of Android Excellence apps and games. These awardees represent some of the best experiences and top performing apps and games on the Play Store and can be found with other great selections on the Editors' Choice page.

If you're looking for some new apps, below are a few highlights.

  • EyeEm: A great photo editor app with a full suite of filters and tools to make your pictures shine. Learn style tips from their community and even sell your images through the EyeEm marketplace.
  • Musixmatch: Check out Musixmatch's updated app while learning the lyrics to all your favorite songs. The app is compatible with many of the top music streaming services and you can even follow along with your Android Wear device or on the big screen with Chromecast support.
  • ViewRanger: Plan your next hiking adventure by discovering new routes and trail guides with ViewRanger. Check out the Skyline feature using your phone's camera to identify over 9 million sites across the world through augmented reality.

Here are a few of our favorite new games joining the collection.

  • Fire Emblem Heroes: Nintendo's popular strategy-RPG franchise is now reimagined for mobile. Fight battles, develop your heroes' skills, and try various gameplay modes for hours of exciting gameplay.
  • Lumino City: Explore the charming papercraft style world in this award-winning puzzle adventure game. The beautiful scenery is all handcrafted.
  • Old Man's Journey: Gorgeous scenery, an immersive soundtrack, and deep emotion help you uncover the old man's life stories while you solve puzzles and shape the landscape to determine his future.

Congratulations to the newly added Android Excellence apps and games.

New Android Excellence apps New Android Excellence games
1tap

Acorns

Airbnb

Blink Health

Blinkist

Clue

Ditty

EyeEm

Fabulous

IFTTT

iReader

Journey

KKBOX

LinkedIn

Mobills: Budget Planner

Musixmatch

Shpock

Stocard

Video Editor

ViewRanger

YAZIO

YOP

Agent A

Bit Heroes

Bloons Supermonkey 2

Dancing Line

DEAD WARFARE: Zombie

Dragon Project

Fire Emblem Heroes

Futurama: Worlds of Tomorrow

Idle Heroes

Last Day on Earth: Survival

Lords Mobile

Lumino City

Modern Combat Versus

Old Man's Journey

The Walking Dead No Man's Land

War Wings

Explore other great apps and games in the Editors' Choice section on Google Play and discover best practices to help you build quality apps and games for people to love.

How useful did you find this blogpost?

A look back at the most read Google Play posts on Medium in 2017

Posted by Sergejs Cuhrajs, Community Manager, Google Play

Earlier this year we launched the Google Play Apps & Games publication on Medium to help developers discover best practices and insights to grow successful apps and games businesses on Google Play. As we draw closer to the end of the year we thought it's a good time to revisit some of our most popular posts according to you – our readers.

It's clear that many of you are excited by the potential of new technology, such as Virtual Reality (VR) and Augmented Reality (AR), and how it could enhance user interaction with your apps and games. You're also concerned with everyday issues including how to keep your APK size manageable, how to acquire new users, and how to monetize games without pushing away your players.

So without further adieu, here's the list of the top 10:

  1. Applying human-centered design to emerging technologies
    (by By Peter Hyer, Fabian Herrmann, and Kristin Kelly, 7 min read)
    VR, AR, and digital assistant present exciting opportunities for the future, but how can we ensure we're designing for what people really want?
  2. Shrinking APKs, growing installs
    (by Sam Tolomei, 6 min read)
    Smaller APK sizes correlate with higher install conversion rate on Google Play - we share tips for keeping your apps lean.
  3. Who plays mobile games?
    (by Allen Bevans, UX Researcher at Google, 6 min read)
    Four actionable insights for game developers based on our research into different player segments.
  4. Why the first ten minutes are crucial if you want to keep players coming back
    (by Adam Carpenter, 7 min read)
    How to analyze your retention data so you can keep players coming back again and again.
  5. Design your app for decision-making
    (by Jeni Fisher, 10 min read)
    Useful tips and strategies for encouraging desired user behavior in your apps. Also check out follow-up posts on boosting motivation through app rewards, and common pitfalls of persuasive app design.
  6. Predicting your app's monetization future
    (by Ignacio Monereo, 10 min read)
    Learn about predictive analytics and calculating your apps lifetime value (LTV) to gain practical insight into the future of your app. In the second part Ignacio shares how to calculate LTV based on five popular monetization models.
  7. Five tips to improve your games-as-a-service monetization
    (by Moonlit Beshimov, 9 min read)
    5 proven strategies to improve your game revenue without driving players away.
  8. An introduction to in-app A/B testing
    (by Gavin Kinghall Were, 13 min read)
    Learn how in-app A/B testing can drive insight into your app's future design and development, and maximise its performance.
  9. Taking the guesswork out of paid user acquisition
    (by David Yin, 8 min read)
    A simple tool to help you estimate lifetime value (LTV) of your users and what to spend to grow your audience.
  10. Rethinking interface assumptions in AR: selecting objects
    (by Aaron Cammarata, 8 min read)
    In this article for beginner AR developers we explore one of the most fundamental user interface actions: object selection.

Do you have suggestions for topics we should tackle in 2018? Let us know by tweeting with the hashtag #AskPlayDev and we'll reply from @GooglePlayDev, where we regularly share news and tips on how to be successful on Google Play.

How useful did you find this blogpost?

Improving app security and performance on Google Play for years to come

Posted by Edward Cunningham, Product Manager, Android

Google Play powers billions of app installs and updates annually. We relentlessly focus on security and performance to ensure everyone has a positive experience discovering and installing apps and games they love. Today we're giving Android developers a heads-up about three changes designed to support these goals, as well as explaining the reasons for each change, and how they will help make Android devices even more secure and performant for the long term.

  • In the second half of 2018, Play will require that new apps and app updates target a recent Android API level. This will be required for new apps in August 2018, and for updates to existing apps in November 2018. This is to ensure apps are built on the latest APIs optimized for security and performance.
  • In August 2019, Play will require that new apps and app updates with native libraries provide 64-bit versions in addition to their 32-bit versions.
  • Additionally, in early 2018, Play will start adding a small amount of security metadata on top of each APK to further verify app authenticity. You do not need to take any action for this change.

We deeply appreciate our developer ecosystem, and so hope this long advance notice is helpful in planning your app releases. We will continue to provide reminders and share developer resources as key dates approach to help you prepare.

Target API level requirement from late 2018

API behavior changes advance the security and privacy protections of Android – helping developers secure their apps and protecting people from malware. Here are a few such changes from recent platform versions:

  • Implicit intents for bindService() no longer supported (Android 5.0)
  • Runtime permissions (Android 6.0)
  • User-added CAs not trusted by default for secure connections (Android 7.0)
  • Apps can't access user accounts without explicit user approval (Android 8.0)

Many of these changes only apply to apps that explicitly declare their support for new API behaviors, through the targetSdkVersion manifest attribute. For example, only apps with a targetSdkVersion of 23 (the API level of Android 6.0) or higher give the user full control over what private data – such as contacts or location – the app can access via runtime permissions. Similarly, recent releases include user experience improvements that prevent apps from accidentally overusing resources like battery and memory; background execution limits is a good example of this type of improvement.

In order to provide users with the best Android experience possible, the Google Play Console will require that apps target a recent API level:

  • August 2018: New apps required to target API level 26 (Android 8.0) or higher.
  • November 2018: Updates to existing apps required to target API level 26 or higher.
  • 2019 onwards: Each year the targetSdkVersion requirement will advance. Within one year following each Android dessert release, new apps and app updates will need to target the corresponding API level or higher.

Existing apps that are not receiving updates are unaffected. Developers remain free to use a minSdkVersion of their choice, so there is no change to your ability to build apps for older Android versions. We encourage developers to provide backwards compatibility as far as reasonably possible. Future Android versions will also restrict apps that don't target a recent API level and adversely impact performance or security. We want to proactively reduce fragmentation in the app ecosystem and ensure apps are secure and performant while providing developers with a long window and plenty of notice in order to plan ahead.

This year we released Android Oreo, the most secure and best performing version of Android yet, and we introduced Project Treble to help the latest releases reach devices faster. Get started building apps that target Android 8.1 Oreo today.

64-bit support requirement in 2019

Platform support for 64-bit architectures was introduced in Android 5.0. Today, over 40% of Android devices coming online have 64-bit support, while still maintaining 32-bit compatibility. For apps that use native libraries, 64-bit code typically offers significantly better performance, with additional registers and new instructions.

In anticipation of future Android devices that support 64-bit code only, the Play Console will require that new apps and app updates are able to run on devices without 32-bit support. Apps that include a 32-bit library will need to have a 64-bit alternative – either within the same APK or as one of the multiple APKs published. Apps that do not include native code are unaffected.

This change will come into effect in August 2019. We're providing advance notice today to allow plenty of time for developers who don't yet support 64-bit to plan the transition. Stay tuned for a future post in which we'll take an in-depth look at the performance benefits of 64-bit native libraries on Android, and check out the CPUs and Architectures guide of the NDK for more info.

Security metadata in early 2018

Next year we'll begin adding a small amount of security metadata on top of each APK to verify that it was officially distributed by Google Play. Often when you buy a physical product, you'll find an official label or a badge which signifies the product's authenticity. The metadata we're adding to APKs is like a Play badge of authenticity for your Android app.

No action is needed by developers or users. We'll adjust Play's maximum APK size to take into account the small metadata addition, which is inserted into the APK Signing Block and does not alter the functionality of your app. In addition to enhancing the integrity of Play's mobile app ecosystem, this metadata will enable new distribution opportunities for developers in the future and help more people keep their apps up to date.

Looking ahead

2017 has been a fantastic year for developers who have seen growth and success on Google Play. We've been hard at work on features (including those announced at I/O 2017 and at Playtime) to help you improve your app quality and business performance. With these features and the upcoming updates, we hope to see the Android and Play ecosystem continue to thrive in 2018 and beyond.

How useful did you find this blogpost?

Celebrating and empowering women in mobile gaming with CHANGE THE GAME

Together, Android and Google Play bring millions of games to more than one billion people in 190 countries, making games accessible to almost everyone. As we continue to create entertainment experiences that cater to each individual person; and with more people gaming on mobile devices than ever before, there’s an opportunity to be even more inclusive—starting with women.

There’s little existing research about women and mobile gaming—so we partnered with Newzoo to learn more about the experiences and perceptions of female mobile players in the U.S. Our study found that 65% of women play mobile games, making-up half of all mobile gamers. In fact, female mobile gamers play more frequently than men with 43% of of them playing more than five days a week compared to just 38% of men.

Despite the fact that women are playing mobile games like never before, only 24.8% of people in the industry identify as women or transgender. This has an impact on women’s behaviors and perceptions of mobile games—for example, we found that the majority of female gamers think that only 30% of those games are actually made for them. Additionally, we found that women are less likely than men to explore multiple genres, talk with friends about mobile games, or identify as a “gamer.”

To tackle this issue, we’re launching CHANGE THE GAME, a new Google Play initiative promoting diversity in games, celebrating all women who play games, and empowering the next generation of game-makers through ongoing research, development programs, and partnerships. The program includes:

  • An interactive experience shining light on the relationship between women and mobile games in the U.S. 
  • A short film celebrating the diversity of women who play mobile games and inviting all women to be part of the game
  • A collection highlighting games with great female protagonists on Google Play’s Indie corner 

This builds on our work to inspire teen girls with the power of games through Wonder Woman, our support of Girls Make Games and the launch of a mobile game development program for emerging game designers. While moving the needle won’t be easy, we hope our commitments to change the game will influence long-term change for women as both players and creators.

Announcing Google Play’s “Best of 2017”

To close out another great year for Google Play, we’re sharing the best and most popular apps, games, music, movies, TV shows and books in 2017.

No one knows how far she can go better than “Moana,” as she landed the most popular movie of the year on Google Play. Strong female characters dominated this year’s movies chart with “Rogue One: A Star Wars Story” and “Wonder Woman” rounding out the top three. “Game of Thrones” kept “Rick and Morty” and “The Walking Dead” at bay to claim the Iron Throne for the second year in a row as the most popular TV show. Elsewhere, Kendrick Lamar may no longer be so “HUMBLE.” after beating out Ed Sheeran’s “Shape of You,” as Google Play’s most streamed song of 2017. Kendrick’s “DNA” also holds the number three spot on this list.

Nintendo’s “Super Mario Run” was the most downloaded new game of the year, but not all bubbles were burst, as “Bubble Witch 3 Saga” was closely behind at number two. "Photo Editor - Beauty Camera & Photo Filters” was the most downloaded new app with fans touching up their favorite photos for social media. We also have curated lists this year from our editors to help you find the best apps and games of 2017, such as “Socratic - Math Answers & Homework Help” and “CATS: Crash Area Turbo Stars,” respectively.

Check out Google Play’s top five lists below for this year’s most popular content in the U.S. You can also discover the most popular lists around the world and all our editors’ choices on the Best of 2017 section of the Play Store.

Safely and quickly distribute private enterprise apps with Google Play

Google Play gives your organization a rich ecosystem of apps for work, enabling your team to be productive from anywhere.

Many businesses use a managed version of Google Play, which allows IT administrators to whitelist specific applications for their team to use. However, sometimes you need a more customized solution, such as custom-built, proprietary apps to conquer specific tasks. Also, with growing popularity of low code development tools, more and more employees are developing apps to serve a company's specific needs, and these need to be managed.

The managed version of Google Play enables you to deploy proprietary apps privately. It gives you all the benefits of Google Play’s high availability, global reach and scale, optimized app delivery, the security of Google Play Protect, and the reassurance that your app remains private to your company.

You can curate private apps alongside public apps on Google Play through your Enterprise Mobility Management (EMM) console. These enterprise apps are then available to your organization directly through the Play Store app - no need for a separate, proprietary enterprise app store. This saves development time and is a more familiar experience for the end users. Users can browse and install the apps that you’ve authorized, or you can push them directly to team members’ devices.

Publish apps without the complexity

Whether you have a dedicated engineering team building in Java, you enable employees to develop apps, or use external development agencies, managed Google Play enables your teams to easily get their apps into the hands of the users that need them.

Following a recent update to Google Play’s app targeting features, any Google Play developer can publish an app privately to an enterprise. This means that not only can developers publish apps internally without complex administrator setup, but this also enables third-party developers, such as agencies, to manage publishing of apps they develop for a client. For more details about targeting the enterprise with private apps, check out this managed Google Play help page.

The new Custom App Publishing API offers additional workflow advantages to those who wish to publish private apps. The API eliminates the need for enterprise IT administrators to access the Google Play Console every time they publish an app. Apps can be published to their managed Google Play directly from the EMM console or Integrated Development Environment (IDE).

Better for security

Every app uploaded to Google Play is scanned for security vulnerabilities. Google Play Protect scans more than 500,000 apps per day. Scanning may flag poor coding practices or usage of old, vulnerable versions of third-party SDKs so they can be mitigated before the app is published, enabling you to be more confident in the security of apps developed internally.

With Google Play Protect constantly working in the background, you can be sure that internal apps are being vetted with the same level of protection that safeguards the Play ecosystem.

Flexibility for large organizations

Private apps can now be targeted to up to 20 EMM tenants. So if your organization is managed regionally, or you have test environments that you need to keep representative of production, you can simply publish the same app across your environments as you need.

EMM chart

It’s as easy as if you were publishing to one tenant. For example, an app can be deployed to different environments as simply as if it was done for just one.

Get started

Our private apps whitepaper details the steps necessary to get started, and highlights many best practices for private app publishing. Much of the publication process is similar to other applications, with the core difference being that distribution is limited to your organization. So teams with experience building apps should be able to make a very easy transition to private app publishing.

Spreading holiday cheer with great deals on Google Play

As temperatures drop, stay warm and entertained with these hot holiday deals on Google Play. Starting today, you’ll be able to find your favorite movies, apps, games, music, TV and books at deep discounts. Just in time for the holidays, these deals for Black Friday and Cyber Monday run through November 27 in select markets.

Battle in your favorite games—not the crowds—on Black Friday.

Avoid store crowds and battle it out with a favorite game instead. Google Play offers discounts of up to 80 percent for premium games, including Call of Duty: Black Ops Zombies, LEGO Ninjago: Shadow of Ronin and LEGO® Jurassic World™  and more. You’ll also get special discounts, power ups and unlimited lives for the perennially popular Gardenscapes and Homescapes games on Google Play.

Set the mood with Google Play Music.

‘Tis the season to start playing songs of cheer. You can get a Google Play Music subscription free for four months, for the right songs to suit your mood anytime.

Survive the season with must-have apps.

When you need a last-minute recipe or a mental break from those holiday errands, Google Play has you covered with discounts on hundred of apps, including a 50 percent discount on a monthly subscription to Colorfy.

Take a turkey break with a movie or TV show.

Once the meal is done and the dishes are cleared, wind down with a favorite classic or a new release as Google Play offers 50 percent off any one movie to own and 25 percent off a TV season of your choice starting on November 23. You’ll also be able to rent any movie for 99 cents for one day only on November 25.

Whether it’s catching up on the latest episodes of “The Walking Dead” or “Outlander,” the latest Minion antics in “Despicable Me 3” or a young Peter Parker in “Spider-Man: Homecoming,” there’s something the entire family can enjoy.

Snuggle in with a good book.

The weather outside may be frightful, but a good book can be delightful. Whether it’s a bedtime story or the latest mystery, Google Play is offering a $5 credit towards any book over $5 and discounts on top titles starting on November 23. You can also find some of the most popular omnibus comics books, including Batman: The Complete Hush, Thor and Flashpoint, for $5 or less on November 25 only.

For more information on these and other deals throughout the season, head to Google Play’s Holiday Hub.

Moving Past GoogleApiClient

Posted by Sam Stern, Developer Programs Engineer

The release of version 11.6.0 of the Google Play services SDK moves a number of popular APIs to a new paradigm for accessing Google APIs on Android. We have reworked the APIs to reduce boilerplate, improve UX, and simplify authentication and authorization.

The primary change in this release is the introduction of new Task and GoogleApi based APIs to replace the GoogleApiClient access pattern.

The following APIs are newly updated to eliminate the use of GoogleApiClient:

  • Auth - updated the Google Sign In and Credentials APIs.
  • Drive - updated the Drive and Drive Resource APIs.
  • Fitness - updated the Ble, Config, Goals, History, Recording, Sensors, and Sessions APIs.
  • Games - updated the Achievements, Events, Games, Games Metadata, Invitations, Leaderboards, Notifications, Player Stats, Players, Realtime Multiplayer, Snapshots, Turn Based Multiplayer, and Videos APIs.
  • Nearby - updated the Connections and Messages APIs.

These APIs join others that made the switch in previous releases, such as the Awareness, Cast, Places, Location, and Wallet APIs.

The Past: Using GoogleApiClient

Here is a simple Activity that demonstrates how one would access the Google Drive API using GoogleApiClient using a previous version of the Play services SDK:

public class MyActivity extends AppCompatActivity implements
        GoogleApiClient.OnConnectionFailedListener,
        GoogleApiClient.ConnectionCallbacks {

    private static final int RC_SIGN_IN = 9001;

    private GoogleApiClient mGoogleApiClient;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        GoogleSignInOptions options =
               new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                        .requestScopes(Drive.SCOPE_FILE)
                        .build();

        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .enableAutoManage(this, this)
                .addConnectionCallbacks(this)
                .addApi(Auth.GOOGLE_SIGN_IN_API, options)
                .addApi(Drive.API)
                .build();
    }

    // ...
    // Not shown: code to handle sign in flow
    // ...

    @Override
    public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
        // GoogleApiClient connection failed, most API calls will not work...
    }

    @Override
    public void onConnected(@Nullable Bundle bundle) {
        // GoogleApiClient is connected, API calls should succeed...
    }

    @Override
    public void onConnectionSuspended(int i) {
        // ...
    }

    private void createDriveFile() {
        // If this method is called before "onConnected" then the app will crash,
        // so the developer has to manage multiple callbacks to make this simple
        // Drive API call.
        Drive.DriveApi.newDriveContents(mGoogleApiClient)
            .setResultCallback(new ResultCallback<DriveApi.DriveContentsResult>() {
                // ...
            });
    }
}

The code is dominated by the concept of a connection, despite using the simplified "automanage" feature. A GoogleApiClient is only connected when all APIs are available and the user has signed in (when APIs require it).

This model has a number of pitfalls:

  • Any connection failure prevents use of any of the requested APIs, but using multiple GoogleApiClient objects is unwieldy.
  • The concept of a "connection" is inappropriately overloaded. Connection failures can be result from Google Play services being missing or from authentication issues.
  • The developer has to track the connection state, because making some calls before onConnected is called will result in a crash.
  • Making a simple API call can mean waiting for two callbacks. One to wait until the GoogleApiClient is connected and another for the API call itself.

The Future: Using GoogleApi

Over the years the need to replace GoogleApiClient became apparent, so we set out to completely abstract the "connection" process and make it easier to access individual Google APIs without boilerplate.

Rather than tacking multiple APIs onto a single API client, each API now has a purpose-built client object class that extends GoogleApi. Unlike with GoogleApiClient there is no performance cost to creating many client objects. Each of these client objects abstracts the connection logic, connections are automatically managed by the SDK in a way that maximizes both speed and efficiency.

Authenticating with GoogleSignInClient

When using GoogleApiClient, authentication was part of the "connection" flow. Now that you no longer need to manage connections, you should use the new GoogleSignInClient class to initiate authentication:

public class MyNewActivity extends AppCompatActivity {

    private static final int RC_SIGN_IN = 9001;

    private GoogleSignInClient mSignInClient;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        GoogleSignInOptions options =
               new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                        .requestScopes(Drive.SCOPE_FILE)
                        .build();

        mSignInClient = GoogleSignIn.getClient(this, options);
    }

    private void signIn() {
        // Launches the sign in flow, the result is returned in onActivityResult
        Intent intent = mSignInClient.getSignInIntent();
        startActivityForResult(intent, RC_SIGN_IN);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == RC_SIGN_IN) {
            Task<GoogleSignInAccount> task = 
                    GoogleSignIn.getSignedInAccountFromIntent(data);
            if (task.isSuccessful()) {
                // Sign in succeeded, proceed with account
                GoogleSignInAccount acct = task.getResult();
            } else {
                // Sign in failed, handle failure and update UI
                // ...
            }
        }
    }
}

Making Authenticated API Calls

Making API calls to authenticated APIs is now much simpler and does not require waiting for multiple callbacks.

    private void createDriveFile() {
        // Get currently signed in account (or null)
        GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);

        // Synchronously check for necessary permissions
        if (!GoogleSignIn.hasPermissions(account, Drive.SCOPE_FILE)) {
            // Note: this launches a sign-in flow, however the code to detect
            // the result of the sign-in flow and retry the API call is not
            // shown here.
            GoogleSignIn.requestPermissions(this, RC_DRIVE_PERMS, 
                    account, Drive.SCOPE_FILE);
            return;
        }

        DriveResourceClient client = Drive.getDriveResourceClient(this, account);
        client.createContents()
                .addOnCompleteListener(new OnCompleteListener<DriveContents>() {
                    @Override
                    public void onComplete(@NonNull Task<DriveContents> task) {
                        // ...
                    }
                });
    }

Before making the API call we add an inline check to make sure that we have signed in and that the sign in process granted the scopes we require.

The call to createContents() is simple, but it's actually taking care of a lot of complex behavior. If the connection to Play services has not yet been established, the call is queued until there is a connection. This is in contrast to the old behavior where calls would fail or crash if made before connecting.

In general, the new GoogleApi-based APIs have the following benefits:

  • No connection logic, calls that require a connection are queued until a connection is available. Connections are pooled when appropriate and torn down when not in use, saving battery and preventing memory leaks.
  • Sign in is completely separated from APIs that consume GoogleSignInAccount which makes it easier to use authenticated APIs throughout your app.
  • Asynchronous API calls use the new Task API rather than PendingResult, which allows for easier management and chaining.

These new APIs will improve your development process and enable you to make better apps.

Next Steps

Ready to get started with the new Google Play services SDK?

Happy building!