JOANNA SMITH: Let's start with Gus.
GUS CLASS: Yeah.
So we're going to talk today about some features of the
Google+ mobile platform.
And these are really timely right now because just last
week there was the release of the Google Play services.
And this lit up these platform features for
Google+ within Android.
And so the three features we're going to highlight today
are the +1, and the share, and then Sign In with Google+.
So Chirag, do you want to tell a little bit more on how this
gets incorporated?
CHIRAG SHAH: Thank you, Gus.
So the Google+ Android SDK actually lives inside Google
Play services.
Google Play services is a platform that lives right next
to Google Play.
This means that it is deployed to all Android devices that
are Froyo and up and that contain Google Play on it.
JOANNA SMITH: Chirag, when you say is deployed, do you mean
it's already been deployed, or it will be?
CHIRAG SHAH: It has already been deployed.
JOANNA SMITH: And users don't have to do anything to update
it themselves?
It's just there and it's ready to go?
CHIRAG SHAH: That is correct.
So you as a developer can assume that the device already
has Google Play services on it if it is Froyo and higher, and
has Google Play installed.
JOANNA SMITH: OK.
CHIRAG SHAH: So what does this mean for you?
This means that your APKs are much smaller when integrating
with Google+.
So practically, this means all of the +1 button assets and
images live inside Google Play services.
And all of the functionality, regarding +1-ing and signing
the user in, lives inside Google Play services.
And you as a developer just need to worry about
integrating the components into your application.
GUS CLASS: Awesome.
So let's talk about share.
So here's an example of someone doing a
share from an app.
So the first thing that happens is that they click the
button that will actually trigger the share.
And then they get a form that's pre-populated with the
text that will be shared.
And then they can select the circles and the people that
they want to share with.
And then finally, after they click Share, then the share
will happen with the content that they populated the Share
interaction with.
And there will also be an annotation from the app.
So Chirag will tell you how this works out in code.
CHIRAG SHAH: So basically, the simplest way you can integrate
the Share button in your application is by adding a
simple button.
In the example Gus showed you earlier, we invoke the Share
through a list item.
So you can integrate the share functionality anywhere in your
application.
So for this example, we're going to have a simple button
incorporated from the Android SDK, and we're going to have
simple text saying Share on Google+.
Next we're going to find the simple share button from your
layout, and set its onClick handler to invoke the Google+
Share dialogue.
So let's deconstruct what's going on in this sample code.
First you build a shareIntent using the shareCompat library.
This library makes it easier for you to build shareIntents
and include rich media for users to share on Google+.
Here in this example, I pass text and a URL
in the setText method.
Next, I used the setType method to identify the type of
content we're sharing as text slash plain.
Finally we call the getIntent method to get the intent we've
built with the shareCompat library.
And finally, we call the setPackage method on the
intent we've obtained.
And we tell it to specify the Google+ application.
And this means that once the intent is launched, it will
directly open the Google+ Share dialog.
JOANNA SMITH: Now Chirag, forgive me if I'm wrong, but
Share isn't exactly a new feature, right?
That's been around since the very beginning of G+, right?
CHIRAG SHAH: Yeah, that is correct.
So here we're launching an attempt to open the Google+
application.
And the Google+ application is responsible for launching the
Share dialogue.
And you, as a developer, can pre-fill the type of text and
URLs that are pre-populated in the Share dialogue.
JOANNA SMITH: OK, so if a developer has already
integrated this share experience into their app, now
that we've added Google Play services, will anything be
affected, or do they need to make any changes?
CHIRAG SHAH: That is correct.
So you won't need to make any changes.
So if you want to add Google Play services, you can get new
features, such as the +1 button and Sign In button.
JOANNA SMITH: OK.
Good to know.
Thank you.
GUS CLASS: Speaking of new features, here's
the mobile +1 button.
Here's an example of the +1 button in the wild.
And what you can see in this example is you can see that
you and Julia Ferraioli have +1'd this item inside of the
Google store.
And so Chirag will tell you about how you can incorporate
this functionality into your own apps.
CHIRAG SHAH: So all you need to do is include the +1 button
in your Android layout.
Here the attributes should look very similar to you
because it inherits from a standard button.
So you can control the layout width, height.
But you can also declare the plus size attribute to declare
the type of--
to declare the appearance of the +1 button.
And this size attribute is very similar to what you'll
see on the web.
We have the small, standard, medium, tall.
Next, you'll initialize the +1 button in
your onCreate handler.
Here, you'll call the initialize method and pass in
the URL that should be +1'd.
JOANNA SMITH: OK, so we have a button-o-matic, basically,
that generates all the code for you for your web.
Do we have anything similar for mobile?
CHIRAG SHAH: So we don't have a o-matic, per
se, for the +1 button--
for the native +1 button on Android.
But the appearance demonstrated through the
+1-o-matic is very similar to the appearance of the +1
button on Android.
For instance, the tall size will be very similar on native
versus the web.
JOANNA SMITH: OK, so--
CHIRAG SHAH: That's a great question.
JOANNA SMITH: OK, so I don't have to go film any new
videos, right?
We're good on that front?
Good to know, good to know.
GUS CLASS: OK, so let's look at an
implementation of the activity.
So this is actually a full implementation.
Chirag will actually break it down into the
important parts for you.
CHIRAG SHAH: So Gus showed you what your activity will look
like once you integrate the full--
you fully integrate the +1 button.
But let's deconstruct what's going on there.
So in your onCreate handler--
you will first initialize the PlusClient object and
initialize the +1 button.
And as you can see when we're +1'ing, or when we're
initializing a +1 button, we'll pass in the URL that
should be +1'd.
Next we'll integrate the PlusClient object in the life
cycle of your Android activity.
So in your onStart handler, you'll call
PlusClient.connect.
This will start to establish a connection between your third
party application and Google Play services.
So your third party application can start to
connect to the resources in Google Play services, and get
the assets for the correct size of the +1 button you've
integrated.
But also control the functionality of the +1 button
you've integrated in your application.
And finally, in your onStop handler, you'll call
PlusClient.disconnect.
And this will terminate the connection between your
application and Google Play services.
And this is a best practice because it will reduce the
number of resources incurred on the device when it's not
being used.
JOANNA SMITH: All right, so we just went through a lot of
different steps.
Is there somewhere online where people can find this
information so they don't have to keep pausing the video and
writing down all the code?
CHIRAG SHAH: That's a great point.
You don't need to take notes.
Put down your pencils.
You can visit developers.googl e.com/plus/mobile.
And from there, you'll find a beautiful getting started
guide and a sample application that you can
follow along with.
And the sample application will look very similar to what
we're covering here in the slides.
GUS CLASS: Thanks, Chirag.
So the last thing we're going to talk about today is going
to be Sign In with Google+.
And so here's another example flow.
Now, a user clicks a Sign In button and then they're
presented with a list of their accounts on
their Android device.
After they select an account, they don't have to enter their
mobile password again because it's saved and
secure on their device.
And then finally, after they're signed in, the
application can open, and some information can
be pulled from Google+.
So Chirag will actually go--
Chirag will go into the integration steps
for the Sign In button.
CHIRAG SHAH: So integrating the Sign In button is very
similar to integrating the +1 button.
But you'll also include the GET_ACCOUNTS permission in
your AndroidManifest file.
This will allow your third party application to obtain
the list of accounts on the device.
Next you'll add the
PlusSignInButton to your layout.
And again, this inherits from a standard button, so the look
and feel of the interface should look very familiar.
GUS CLASS: So here's actually a full implementation of the
Plus Sign In button.
Don't freak out.
Chirag will actually break down the important pieces of
this code so it's easier for you to understand.
CHIRAG SHAH: So the first important thing you'll do is
sign the user in.
And again, you will integrate the PlusClient object in the
life cycle of your Android activity.
So when your onStart handler is invoked, you'll call
PlusClient.connect.
But now in this case, two things can happen when
PlusClient is invoked.
Google Play services can go in and invoke your
onConnectionFailed handler, or your onConnected handler.
Next, you will invoke--
next, you'll implement your onStop handler.
And again, you'll call PlusClient.disconnect to
terminate the connection between your application and
Google Play services.
So as I mentioned before, either onConnected is invoked
from Google Play services, or onConnectionFailed is involved
from Google Play services.
onConnected is analogous to the user being signed in.
And when that method is invoked, you can update your
user interface to reflect that the user is signed in.
If the user is not signed in, your onConnectionFailed
handler will be invoked.
And with that, the Google Play services will pass in a
connection result.
You'll hang on to this connection result, and you'll
resolve it when the user presses the Sign In button.
Now we save ConnectionResult as a member
variable in our activity.
And when the user presses the Sign In button, our onClick
handler will be invoked, and we'll call--
we'll start resolving the connection result we saved in
the member variable.
And here we call mConnectionResul
t.startResolutionForResult.
And we pass in a request code, so we can get a handle on it
once a response comes back.
So now let's look at the onActivityResult handler.
Whenever the activity comes back, we'll capture the
request code and we'll see if it worked out OK.
If the resolution worked out correctly, we'll call
PlusClient again and complete the signing in of the user.
JOANNA SMITH: Now wait.
So because this is all using Google Play services, which
lives inside of the Android--
or the Android SDK lives inside of Google Play
services, they can do all this without including any of
Google Play services in their own ADK, right?
CHIRAG SHAH: That is slightly true.
All of the complicated logic of Google Play services, and
all of the image assets of the +1 button and Sign In button
will live on the device, but you'll include a lightweight
jar to start establishing a connection between your
application and Google Play services.
So you can obtain that jar from the Google Android SD--
from the Android SDK manager.
And it's a very lightweight jar that simply connects to
Google Play services.
JOANNA SMITH: OK, that makes sense then.
GUS CLASS: Great.
So that's pretty much all we have to talk to you guys today
about for updates for Google+ for mobile developers.
As always, remember you can get all the resources that
we've talked about from the Google Developer
documentation.
And you can also ask questions on our Google+ page.
And we'll try to get to them in these office hours.
And we can also try to get to them independently of this if
you guys have questions
JOANNA SMITH: Exactly.
So I'm going to monitor for the next few minutes while we
continue to talk.
But if you think of anything later, if you're watching the
YouTube video, we'll try to check back fairly regularly in
the next few days to see if we can help you out again.
In the meantime, so, Lee, you've been listening with
rapt attention for this whole thing.
Do you have any comments or questions or just insights
into what we've been talking about today?
LEE DENISON: So one question I have for you, Chirag, is now,
with Google Play Services being deployed to these
Android devices, you said earlier that when I embed a
Share button into my application, it uses the share
dialog from the Plus application.
Do users still need to have the Plus application installed
for me to be able to do that?
CHIRAG SHAH: Yeah, that is correct.
So the user will need to have the Google+ Android
application installed on their device for the Share dialogue
to prompt up.
And in Google Play services, we offer a helper utility to
check if the Google+ application is installed.
If it is installed, you can continue and create your
shareIntent using the shareCompat library, and
launch the Share dialogue.
But if the user does not have the Google+ application
installed, they can go out to the market and install it, and
then go back and resume sharing the content
they want to share.
So that's a good question.
JOANNA SMITH: And Gus, I know that we first surfaced some of
this documentation at Google I/O this year, and then we
went into developer preview.
So what does it mean for developers now that we're out
of the developer preview phase?
What does that mean for these features?
GUS CLASS: One second.
I have to cough.
[COUGHS]
JOANNA SMITH: Not allowed.
GUS CLASS: But yeah, so the big difference between the
functionality that we announced at I/O and today is
that at I/O, the Google Play services had not been out yet.
And so this functionality, we knew that it was going to be
coming, and so we had that developer preview.
But now that Google Play services is out, all of this
is lit up on devices, and so the
functionality is available.
JOANNA SMITH: And so anybody, regardless of the preview
group, is now able to develop with it, and with the full
access to the Google Play services?
GUS CLASS: Yeah.
So now, within your apps, that functionality like the +1
button is available.
And up until this release last week, it was not
possible to do this.
JOANNA SMITH: OK, that's good to know.
Lee, anything else while we wait?
LEE DENISON: One other question I did have actually,
is if you use a Sign In button, and you would like, in
your application, to maybe at some critical point
re-authenticate the user, is that possible?
CHIRAG SHAH: So once the user signs in, they've identified
themselves with the application.
In the application, it's effectively single sign-on.
So the onConnected method will re-trigger if you rotate the
device, or you put the activity to sleep for a
certain amount of time, the activity will resume and will
call connect again, and onConnected will be invoked,
and the user is authenticated.
So the only thing--
if you swap users on the device.
Like if I sign out--
if I remove my Gmail account on my device, and add Gus on
it, he would have to re-identify himself to the
application.
And then once he returns it back, I'd
add my accounts back.
LEE DENISON: Cool.
Thanks.
JOANNA SMITH: OK.
So slightly off-topic, we actually had a question posted
on the GL event on Google+ a while ago.
And this person wants to ask about Hangouts.
And they didn't know how to get their app started, so I
directed them to our forum so that they could start
looking into that.
But one question that seems to be at the core of this that I
think it's worth at least discussing is, they want to
know about integrating Google+ Hangouts
directly into their site.
Now maybe you can illustrate why now this is possible with
the current API, or any insight you have into how this
might be done.
Because I don't-- as far as I know-- and I'm new-- but I
don't think that it's actually possible at
this point in time.
Is that correct?
CHIRAG SHAH: Yeah, that is correct.
You can't integrate a Hangout within your application.
But you can add the Hangouts button to invoke a Hangout
into a new window.
JOANNA SMITH: OK, so it still launches from Google+, but the
button lives on your own site.
CHIRAG SHAH: Yeah, you can use the Simple Hangout button.
And it will create a new window, or it
will open a new tab.
JOANNA SMITH: OK, cool, so Jeremy, I hope this helps you
get started, at least with where to look.
And as always, please post in our forum.
We don't really know how to help you with implementation
details, but we would hopefully like to see other
people helping you out, and help you find all the
information you need.
I'm not seeing any other comments appearing on our
YouTube page.
[LAUGHS]
One person comments on our G+ event that they would like a
suggestion for Google+ where you can join a streaming event
from a Nexus tablet.
So they're looking for mobile support for joining a
streaming event.
We'll work on that.
In the meantime, we're going to post this on YouTube after
we finish recording.
So you can always go back and watch it after the fact.
So anyone else have anything to say?
LEE DENISON: Not for me.
JOANNA SMITH: All right.
Well then I have, actually, an announcement about Hangouts,
which is that version 1.3 was just released.
This is really exciting, because it has a normalizing
feature, which is where you can mirror yourself.
So let's say, I go into a Hangout.
And my face comes up as I'm prepping and primping to make
sure I look cute enough in my pajamas to talk to my sister.
But I look weird, because I'm backwards.
And I don't like that flopped image.
So now I can mirror it.
And it doesn't mirror for my sister.
It just mirrors for myself so that I look normal to me as
well as normal to her.
And I think this is a really great feature for perspective.
And I really like playing with it too.
So I encourage you to play with 1.3 and start playing
with that yourself.
And one last check at our comments.
And I'm not seeing anything, so at the request of our
visiting guest, I'm going to make a really bad pun.
And then we're going to say goodbye.
So, how do you get holy water?
Anyone?
GUS CLASS: How do you do it?
JOANNA SMITH: You boil the hell out of it.
[WEAK LAUGHTER]
GUS CLASS: Thanks, everyone.
JOANNA SMITH: Bye.
GUS CLASS: Bye.
[MUSIC PLAYING]