GooglePlusLoginUtil


Source link: https://github.com/kpbird/GooglePlusLoginUtil/

Login with Google Plus Utility

Pre-requisite###

Official Document: https://developers.google.com/+/mobile/android/sign-in

Tutorial from AndroidHive : http://www.androidhive.info/2014/02/android-login-with-google-plus-account-1/

Note: Please read AndroidHive article for initial setup & other process

Usage

Step 1: Import "GooglePlusLoginUtils.java" class in your package

Step 2: Implement callback listener

public class LoginActivity extends Activity implements GooglePlusLoginUtils.GPlusLoginStatus  

Step 3: Declare callback method

public void OnSuccessGPlusLogin(Bundle profile) {
  Log.i(TAG,profile.getString(GooglePlusLoginUtils.NAME));

Log.i(TAG,profile.getString(GooglePlusLoginUtils.EMAIL));
  Log.i(TAG,profile.getString(GooglePlusLoginUtils.PHOTO));
  Log.i(TAG,profile.getString(GooglePlusLoginUtils.PROFILE));
 
}
 

Step 4: Declare object of GooglePlusLoginUtils.java

private GooglePlusLoginUtils gLogin; 

Step 5: Initialize object in onCreate method

 gLogin = new GooglePlusLoginUtils(this, R.id.activity_login_gplus);
 // Id of login button
  gLogin.setLoginStatus(this);
 

Step 6: Declare few supporting methods

@Override protected void onStart() {

super.onStart();

gLogin.connect();

  
}

  @Override
  protected void onStop() {

super.onStop();

gLogin.disconnect();

  
}

  @Override
  protected void onActivityResult(int requestCode, int responseCode,

 Intent intent) {

gLogin.onActivityResult(requestCode, responseCode, intent);

}
 

FAQ###

Q: What is the problem of above approach ?

A: You activity has a lot of scattered code for Google Pluse login, It will be more complex and unmanageable when you will have another social network login like Facebook and Twitter.

Q: How I will receive a response for login success?

A: You need to implement interface "GPlusloginStatus", on successful login you will receive callback "OnSuccessGPlusLogin"

Q: What will be received on login success ?

A: You will have Display name, Email , Photo and Profile url.

Q: Do I need to handle login failure / error ?

A: No, GooglePlusLoginUtils.java will handle login failure, error and display appropriate message on screen.

Resources

A simple layout for displaying tickets, booking result with qr codes and pnr etc...

This is a indeterminate progress indicator for android that shows a dots bouncing animation for the progress indicator.

The dots are configurable for quantity, colour, size and spacing. There is also a built in show/hide delay feature that solved for the progress indicator flashing issue.

Add support for emoticons and GIF easily. EmoticonGIFKeyboard is an easy to integrate, customizable and lightweight library to add support for emojis and GIFs.

The easy way to take screenshots of your application programmatically.

Newtron Watchdog allows the critical applications you develop for Android to keep running even after an application crash.

Love Architecture Components' ViewModels but hate how hard it is to instantiate them?

Hire Alfred and start doing just this!

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes