我正在使用PlusShare.Builder
与google plus共享网址,但不会渲染。
当我只是在google plus中复制粘贴网址时,它的呈现成功,但在android端它无效。
这是我的URL
Plz引导我使用我的代码..我的代码中缺少任何内容。
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);
}
答案 0 :(得分:3)
你试过吗
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);
检查来源,以防您没有正确配置:https://developers.google.com/+/mobile/android/share/deep-link
如果addCallToAction仍然有用,那么IDK仍然有用,因为根据文档https://developers.google.com/android/reference/com/google/android/gms/plus/PlusShare.Builder#addCallToAction(java.lang.String,%20android.net.Uri,%20java.lang.String),它需要在构建器中使用已登录的PlusClient,但在更新的播放服务中它不再可用:https://stackoverflow.com/a/31654018/6248510
希望有所帮助