简体   繁体   English

如何从Android应用程序发布Google Plus中的图像和链接URL?

[英]How post Image and Link URL in Google Plus from Android Application?

i have try to post Image from server and link URL both in google plus from android application.. but i can't post both in google plus.. 我试图从谷歌加上从Android应用程序发布服务器和链接URL图像..但我不能在谷歌加两个发布..

i have try this code to post.. 我试过这段代码发布..

Intent shareIntent = new 

PlusShare.Builder(GooglePlusActivity.this)
                  .setType("text/plain")
                  .setText("Welcome to the Google+ platform....")

                  .setContentDeepLinkId("/cheesecake/lemon", 
                          "Lemon Cheesecake recipe", 
                          "A tasty recipe for making lemon cheesecake.",
                          Uri.parse("http://www.onedigital.mx/ww3/wp-content/uploads/2012/02/android-420x315.jpg"))
                  .setContentUrl(Uri.parse("https://developers.google.com/+/"))
                  .getIntent();`

In tthis code i have only post a image but not post URL.. URl is display but it not clickable. 在这段代码中,我只发布了一张图片但没有张贴网址。现在显示URl但不可点击。

some one give me solution for my problem.. 有人给我解决我的问题..

You need google-play-services_lib library project. 你需要google-play-services_lib库项目。 Just import it in workspace in add in your project. 只需在项目中的工作区中导入它即可。

You can find it at .../android-sdk-linux_x86/extras/google/google_play_services/libproject 你可以在... / android-sdk-linux_x86 / extras / google / google_play_services / libproject找到它

And use this code for sharing on google-plus via google-plus application. 并使用此代码通过google-plus应用程序在google-plus上共享。

final int errorCode = GooglePlusUtil.checkGooglePlusApp(mActivity);
if (errorCode == GooglePlusUtil.SUCCESS) {
// Invoke the ACTION_SEND intent to share to Google+ with attribution.
Intent shareIntent = ShareCompat.IntentBuilder.from(mActivity)
                                .setText("")
                                .setType("text/plain")
                                .getIntent()
                                .setPackage("com.google.android.apps.plus");
    startActivity(shareIntent);
} else {
    Toast.makeText(mActivity, "Google plus not installed", Toast.LENGTH_LONG).show();
}

The solution is to share an image and give the URL in the accompanying text. 解决方案是共享图像并在随附文本中提供URL。 See the PlusShare documentation: 请参阅PlusShare文档:

https://developers.google.com/+/mobile/android/share/media https://developers.google.com/+/mobile/android/share/media

It says: When you share media to Google+, you cannot also use the setContentUrl method. 它说: 当您向Google+分享媒体时,您也不能使用setContentUrl方法。 If you want to include a URL in the post with the media, you should append the URL to the prefilled text in the setText() method. 如果要在包含媒体的帖子中包含URL,则应将URL附加到setText()方法中的预填充文本。

Add your media url with text message in .setText field .setText字段中添加带有文本消息的媒体网址

 Intent shareIntent = ShareCompat.IntentBuilder.from(activity) .setType("text/plain") .setText("Sharing text with image link \\n "+***url***) .setStream(null) .getIntent() .setPackage("com.google.android.apps.plus"); activity.startActivity(shareIntent); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM