Courtesy: GitHub

Google Sign-In Quickstart

The Google Sign-In Android quickstart demonstrates how to authenticate a user with GoogleSignInClient.

Introduction

Getting Started

  • Follow the quickstart guide to set up your project in Android Studio.
  • Run the sample on your Android device or emulator.
  • The running sample allows Google accounts on the device to sign-in.

Screenshots

Screenshot

Support

If you've found an error in this sample, please file an issue: https://github.com/googlesamples/google-services/issues

Patches are encouraged, and may be submitted by forking this project and submitting a pull request through GitHub.

License

Copyright 2015 Google, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

compileSdkVersion 26

applicationId "com.google.samples.quickstart.signin"

minSdkVersion 18

targetSdkVersion 26

versionCode 1

versionName "1.0"

compile 'com.android.support:appcompat-v7:26.1.0'

compile 'com.android.support:design:26.1.0'

compile 'com.google.android.gms:play-services-auth:11.6.0'

compile 'com.google.api-client:google-api-client:1.22.0'

compile 'com.google.api-client:google-api-client-android:1.22.0'

compile 'com.google.apis:google-api-services-people:v1-rev139-1.22.0'

compileSdkVersion 25

applicationId "com.google.samples.quickstart.signin"

minSdkVersion 18

targetSdkVersion 25

versionCode 1

versionName "1.0"

compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:appcompat-v7:25.2.0'

compile 'com.android.support:design:25.2.0'

compile 'com.google.android.gms:play-services-plus:9.6.1'

package com.google.samples.quickstart.signin

package com.google.samples.quickstart.signin

uses-permission

  • android.permission.GET_ACCOUNTS

MainActivity

MainActivity

~~~~~ WARNING ~~~~~

This class is DEPRECATED. While it will continue to work, see {@code SignInActivity} for best practices when using Google Sign In with Google Play Services 8.3.0 or greater.

Check if we have the GET_ACCOUNTS permission and request it if we do not. @return true if we have the permission, false if we do not.