Reputation: 5269
I am sharing URL to google plus using PlusShare.Builder
but its not rendering.
Its render successfully when i simply copy paste URL in google plus, but in android side its not working.
this is my URL
Plz guide me with my code.. is there anything missing in my code.
private void shareToGooglePlus(String urlToShare){
PlusShare.Builder builder = new PlusShare.Builder(getActivity());
// 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/share?url="+ urlToShare));
// Set the share text.
builder.addStream(Uri.parse(urlToShare));
builder.setText(urlToShare);
startActivityForResult(builder.getIntent(), 0);
}
Upvotes: 4
Views: 128
Reputation: 3916
Have you tried
Intent shareIntent = new PlusShare.Builder(this)
.setText("CREATE_ITEM")
.setType("text/plain")
.setContentUrl(Uri.parse("https://plus.google.com/share?url="+ urlToShare)
.setContentDeepLinkId(Uri.parse("/pages/create"))
.getIntent();
startActivityForResult(shareIntent, 0);
Check the source just in case you don't have something configured correctly: https://developers.google.com/+/mobile/android/share/deep-link
And IDK if addCallToAction can still be of use because according to the docs https://developers.google.com/android/reference/com/google/android/gms/plus/PlusShare.Builder#addCallToAction(java.lang.String,%20android.net.Uri,%20java.lang.String) it requires a signed-in PlusClient in the builder, but it is not available anymore in the updated play services: https://stackoverflow.com/a/31654018/6248510
Hope it helps
Upvotes: 3