Mooscon 2013 cebit - google integration in android apps (1)

31
Google Integration in Android Apps Ronan Schwarz and Friedger Müffke Moosecon - 8 March 2013

description

 

Transcript of Mooscon 2013 cebit - google integration in android apps (1)

Page 1: Mooscon 2013   cebit - google integration in android apps (1)

Google Integration in Android AppsRonan Schwarz and Friedger Müffke

Moosecon - 8 March 2013

Page 2: Mooscon 2013   cebit - google integration in android apps (1)

Android and Google

● Android Open Source Project (AOSP)all, cheap, free

● Open Handset Alliance84 companies, Google governance

● Android Update Alliancepromise to update

● Google User ExperienceCTS and relevance

Page 3: Mooscon 2013   cebit - google integration in android apps (1)

Google for developers so far

● Some Content Provider API, e.g. calendar contract

● Intents to launch appse.g. Navigation

● Java libs and Web APIse.g gdata client lib to connect to Google Docs

Page 4: Mooscon 2013   cebit - google integration in android apps (1)

Google Play Framework (gms)

● Requires Android 2.2 and Google Play

● APK that provides APIs to Google services

● Service APK will and must be installed automatically

Page 5: Mooscon 2013   cebit - google integration in android apps (1)

Google Play Framework (gms)

Requires real device

Page 6: Mooscon 2013   cebit - google integration in android apps (1)

Helper methods

● Always check for availability first!

● Use isGooglePlayServicesAvailable() in onResume

● Give the user a chance to install the missing file with getErrorDialog()

● getOpenSourceSoftwareLicenseInfo()

Page 7: Mooscon 2013   cebit - google integration in android apps (1)

Authentication

http://www.flickr.com/photos/carlosluzz/

Page 8: Mooscon 2013   cebit - google integration in android apps (1)

Authentication

● OAuth2 through GoogleAuthToken class

● get the Google Account(s) by○ AccountManager

○ AccountPicker.newIntent()

● Email needed for retrieving auth token

● getToken() for UI components

● getTokenWithNotification() for Services

Page 9: Mooscon 2013   cebit - google integration in android apps (1)

Authentication Error Handling

● User Recoverable Error○ UserRecoverableAuthException

○ GooglePlayServicesAvailabilityException

○ UserRecoverableNotifiedException

● Non-Recoverable Error○ GoogleAuthException

Page 10: Mooscon 2013   cebit - google integration in android apps (1)

Google Plus

Page 11: Mooscon 2013   cebit - google integration in android apps (1)

Google Plus

● Updated on 26 February 2013

● Policy ○ not to misuse personal data and +1 links○ only use Google provided branding○ provide means to revoke authorization

Page 12: Mooscon 2013   cebit - google integration in android apps (1)

Google Plus: Setup

ServicesOAuth2 client

Page 13: Mooscon 2013   cebit - google integration in android apps (1)

Google Plus: Setup

Identify each client

Page 14: Mooscon 2013   cebit - google integration in android apps (1)

PlusClient: initialize

PlusClient.Builder()...build()

PlusClient.connected() and .disconnected() within component lifecycle

All calls are asyncronous .onConnected() and .onDisconnected()

Page 15: Mooscon 2013   cebit - google integration in android apps (1)

PlusClient: Sign-In

● Visual user consent <com.google.android.gms.common.SignInButton

android:id="@+id/sign_in_button" android:layout_width="wrap_content" android:layout_height="wrap_content" />

● startResolutionForResult() on click

● optional sign-out button● required revoke method with deletion of data

Page 16: Mooscon 2013   cebit - google integration in android apps (1)

PlusClient: Social Graph

● Profile of the user mPlusClient.loadPerson(this, "me"); // or "108591961893121462921"

● People in the circles of the usermPlusClient.loadPeople(this, Person.Collection.VISIBLE);

● Email address (PlusClient.getAccountName()) requires additional permission GET_ACCOUNTS

Page 17: Mooscon 2013   cebit - google integration in android apps (1)

PlusClient: App Activities

AddActivityBuyActivityCheckInActivityCommentActivityCreateActivityDiscoverActivityListenActivityReserveActivityReviewActivityWantActivity

● Moments: "possibility to share what user has done in the app"

● Prepare snippet

(or let prepare) ● writeMoment(moment)

● removeMoement(moment)● listMoments()

Page 18: Mooscon 2013   cebit - google integration in android apps (1)

PlusShare: Share Content

● Simple share intent PlusShare.Builder.getIntent()

● Deep linking setContentDeepLinkId() setContentUrl()

● Interactive posts

addCallToAction() ● Can be ActionBar or (standard) Button● Breaks ShareActionProvider

Page 19: Mooscon 2013   cebit - google integration in android apps (1)

PlusShare: Deep Linking

● Intent filter in Manifest<activity android:name=".ParseDeepLinkActivity"> <intent-filter> <action android:name="com.google.android.apps.plus.VIEW_DEEP_LINK" /> <data android:scheme="vnd.google.deeplink" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> </intent-filter></activity>

● Extract deep link idPlusShare.getDeepLinkId(this.getIntent());

Page 20: Mooscon 2013   cebit - google integration in android apps (1)

PlusOneButton: Recommendations

● Add a +1 Button to anything <com.google.android.gms.plus.PlusOneButton xmlns:plus=

"http://schemas.android.com/apk/lib/com.google.android.gms.plus" plus:size="standard"/>

● One URL per buttonmPlusOneButton.initialize(mPlusClient, URL);

● No Meta-Data

Page 21: Mooscon 2013   cebit - google integration in android apps (1)

Over-the-air install (7 March)

● Setup web client

● Sign-in Button + app package name

● Quality control by Google (?)

Page 22: Mooscon 2013   cebit - google integration in android apps (1)

Google Maps: V2

Page 23: Mooscon 2013   cebit - google integration in android apps (1)

Google Maps: V2

● Fragments!

● Fragments for older Devices!

● Views!

● Activities ?

● Breaks compatibility.

Page 24: Mooscon 2013   cebit - google integration in android apps (1)

Google Maps: Camera

● 2-Axis Rotation

● Perspective View

● Zoom

● Move

● Target

Page 25: Mooscon 2013   cebit - google integration in android apps (1)

Google Maps: Markers

● Default Markers

● Customize

Appearance

● Show InfoWindow

● InfoWindow != View

● Add/Remove

Markers manually

Page 26: Mooscon 2013   cebit - google integration in android apps (1)

Google Maps: Custom Drawing

● Lines

● Circles

● Polygons

● Points are Lat,Long pointsPolygon polygon = map.addPolygon(

new PolygonOptions() .add(new LatLng(0, 0), new LatLng(0, 5), new LatLng(3, 5)) .strokeColor(Color.RED) .fillColor(Color.BLUE));

Page 27: Mooscon 2013   cebit - google integration in android apps (1)

Goodies

http://www.flickr.com/photos/g-alain/

Page 28: Mooscon 2013   cebit - google integration in android apps (1)

ImageManager

● Load Images from an external resource in

the background

● Can specify a default resource for errors etc

● As easy as loadImage(ImageView,Uri,defaultResId)

● Only G+ URL's

● For everything else use the novoda

ImageLoader on github.com/novoda

Page 29: Mooscon 2013   cebit - google integration in android apps (1)

PanoramaClient

● Load from URL

● Load from ContentProvider

● Zoom and Rotate

Page 30: Mooscon 2013   cebit - google integration in android apps (1)

Hints

● Debugadb shell setprop log.tag.GooglePlusPlatform VERBOSE

● Lot's of example codes and documentation at https://developer.android.com/google/play-services/index.html

● G+ Bootcamp for companieshttp://googleplusplatform.blogspot.de/2013/03/global-google-sign-in-bootcamps.html

Berlin, Germany - March 18th - March 22nd

More to come...

Page 31: Mooscon 2013   cebit - google integration in android apps (1)

Questions

Ronan SchwarzFriedger Müffke

novoda.com@novoda#moosecon