Sharing to Google+ from your Android app

The Share dialog provides a means for users to share rich content from your app into the Google+ stream, including text, photos, URL attachments and location. In addition, your app can use two advanced sharing options: interactive posts and deep linking.

Additional examples demonstrate how to share interactive posts, upload media with posts, use deep linking, and prefill the share dialog.

Before you begin

You must create a Google Developers Console project and initialize the GoogleApiClient object.

Adding basic sharing

Basic sharing demonstrates the minimum code that is required to add sharing to Google+ from your app. You set up sharing by using the PlusShare.Builder methods, which you later build on to add advanced sharing features.

To add sharing:

  1. Add a share button to your layout.

      android:text="Share on Google+"
  2. In your activity, configure your button's OnClickListener to share when clicked.

    Button shareButton = (Button) findViewById(R.id.share_button);
    shareButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
          // Launch the Google+ share dialog with attribution to your app.
          Intent shareIntent = new PlusShare.Builder(this)
              .setText("Welcome to the Google+ platform.")
          startActivityForResult(shareIntent, 0);

Next, you can build on this code to add advanced features such as deep linking or interactive posts.

Additional sharing options

You might also want to explore the following approaches to sharing content from your app:

Next steps

Send feedback about...

Google+ Platform for Android