Crouching Sharebox, Hidden Android

With all the share box related things happening over the last week or so, I realised there are a couple of non-obvious parts of the Android PlusShare class which might be of interest to people.

Google Play Services Share box

I actually had to test for myself to verify this feature of Google Play Services, which I was aware of but hadn't actually tried! If you are building an app which include Google+ sharing, you might be used to it firing an intent to the Google+ app which gives you the familiar Google+ sharing experience.

Because the Google+ app comes with many devices, you may not have worried too much about what would happen if it wasn't available, but the Google+ Android platform team did. So they actually built a backup share box right into Google Play Services. You call it just like you would with the regular share box - if Google+ is installed it will be used, otherwise the Google Play Services share box will be handle the intent instead.

Its a little bit simpler than the primary share box, but does the job and allows users to share to their Google+ circles even when they don't have the Google+ app installed on their device. Note that the Google Play Services share box only handles the "text/plain" type - so you can't use it to share videos or images!

PlusShare createPerson

One of the tips in Gus and Joanna's Google I/O best practices talk was to supply some recipients when creating a share, in order to encourage targeted sharing. There have been some really interesting uses of that: for example, Mashable use it on the web with interactive posts to encourage conversation by giving you a "discuss" button, then adding the user that shared with you as a recipient.


If you want to do something like this then you may know the name and ID of the user, but not have an Android Person object for them because they're not in the user's circles. Luckily, PlusShare has a helper method that makes creating a user for this purpose easy. If I wanted to fill in Silvano as a sharing suggestion for users of my app, I could do so like this:

Popular posts from this blog

Client-Server Authentication with ID tokens

Common problems with Google+ Sign-In on Android

Upgrading Firebase.com & Using Google Sign In on Android