Interactive posts provide an easy and prominent way to allow users to share your site or app with their friends and invite them to take a specific action, for example RSVP to an event or take part in a discussion. Interactive posts can drive new users to your app, improve conversions, and increase engagement.

Before you begin
If you plan on building deep linking into your app, you must create a client ID for each platform that you plan on supporting within the same Google Developers Console project.
If your app uses Google+ Sign-in, you must create a Google Developers Console project
and initialize the GoogleApiClient
object.
Choose a call-to-action label
Choose a value from the following list to designate the label for the call-to-action button.
ACCEPT ACCEPT_GIFT ADD ADD_FRIEND ADD_ME ADD_TO_CALENDAR ADD_TO_CART ADD_TO_FAVORITES ADD_TO_QUEUE ADD_TO_WISH_LIST ANSWER ANSWER_QUIZ APPLY ASK ATTACK BEAT BID BOOK BOOKMARK BROWSE BUY CAPTURE CHALLENGE CHANGE CHAT CHECKIN COLLECT COMMENT COMPARE COMPLAIN CONFIRM CONNECT CONTRIBUTE COOK CREATE DEFEND DINE DISCOVER DISCUSS DONATE DOWNLOAD EARN EAT EXPLAIN FIND FIND_A_TABLE FOLLOW GET GIFT GIVE GO HELP IDENTIFY INSTALL INSTALL_APP INTRODUCE INVITE JOIN JOIN_ME LEARN LEARN_MORE LISTEN MAKE MATCH MESSAGE OPEN OPEN_APP OWN PAY PIN PIN_IT PLAN PLAY PURCHASE RATE READ READ_MORE RECOMMEND RECORD REDEEM REGISTER REPLY RESERVE REVIEW RSVP SAVE SAVE_OFFER SEE_DEMO SELL SEND SIGN_IN SIGN_UP START STOP SUBSCRIBE TAKE_QUIZ TAKE_TEST TRY_IT UPVOTE USE VIEW VIEW_ITEM VIEW_MENU VIEW_PROFILE VISIT VOTE WANT WANT_TO_SEE WANT_TO_SEE_IT WATCH WATCH_TRAILER WISH WRITE
Configure the share dialog
The steps for adding interactive posts to your app builds on the steps for implementing basic sharing. Interactive posts can have deep links attached to both the content URL and the callt-action button.
To create interactive posts when a user clicks on the share button:
-
Add a share button to your layout named
share_activity.xml
.<Button android:id="@+id/share_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Share interactive post on Google+" android:enabled="false" />
-
Initialize the share button in your
Activity.onCreate
handler. Configure your share button'sOnClickListener
to invoke youronClick
handler.@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.share_activity); mShareButton = (ImageButton) findViewById(R.id.share_button); mShareButton.setOnClickListener(this); }
-
Configure your
onClick
handler to send the interactive post:@Override public void onClick(View view) { switch (view.getId()) { case R.id.share_button: PlusShare.Builder builder = new PlusShare.Builder(this); // Set call-to-action metadata. builder.addCallToAction( "CREATE_ITEM", /** call-to-action button label */ Uri.parse("http://plus.google.com/pages/create"), /** call-to-action url (for desktop use) */ "/pages/create" /** call to action deep-link ID (for mobile use), 512 characters or fewer */); // Set the content url (for desktop use). builder.setContentUrl(Uri.parse("https://plus.google.com/pages/")); // Set the target deep-link ID (for mobile use). builder.setContentDeepLinkId("/pages/", null, null, null); // Set the share text. builder.setText("Create your Google+ Page too!"); startActivityForResult(builder.getIntent(), 0); break; } }
The protocol (http/https), host name, and port (if specified) for the content URL and the call-to-action URL must match. Because these must match, you should avoid using URL shorteners and redirects for either URL.
If you choose to use deep linking, you should configure your app to handle the incoming deep links.