GoogleApi

Kotlin|Java

public abstract classGoogleApi<O extends Api.ApiOptions> implementsHasApiKey

Known direct subclasses
GoogleSignInClient

This class is deprecated.

UseCredential Manager for authentication orGoogle Identity Services for authorization.


Base class for Google API entry points. API clients based on this class manage the connection between your app and Google Play services (as opposed toGoogleApiClient-based calls).

GoogleApi-based instances enqueue calls until a connection is made to Google Play services, and then execute them in order. The instances are:

  • "Cheap" to create
  • Thread-safe
  • Automatically deduplicated
  • Automatically timed-out and reconnected when necessary

GoogleApi abstracts the connection to Play services, so callers do not need to implementGoogleApiClient.ConnectionCallbacks.

If the user needs to install or update Google Play services,GoogleApi will prompt the user to do so and enqueue API calls until the issue is resolved. IfGoogleApi was initialized with anActivity it will create a foreground prompt, otherwise it will display a system notification. If the user cancels the resolution or some other issue arises, pending API calls will be fail with anApiException and status codeCommonStatusCodes.API_NOT_CONNECTED.

If isGooglePlayServicesAvailable returnstrue,GoogleApi instances will not show any UI to resolve connection failures.

Summary

Protected methods

@NullableString

This method is only invoked on versions below Android R, where no attribution tag is available.

Protected methods

getApiFallbackAttributionTag

protected @NullableString getApiFallbackAttributionTag(Context context)

This method is only invoked on versions below Android R, where no attribution tag is available. If APIs have some other type of client identifier they wish to use, they may implement this method in order to provide their own fallback which will be used in place of the attribution tag (and thus passed through client/module implementations as the attribution tag).

This method is invoked from the constructor, and should be careful not to reference uninitialized members or allow references to escape.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-03-17 UTC.