【问题标题】:How post Image and Link URL in Google Plus from Android Application?如何从 Android 应用程序在 Google Plus 中发布图片和链接 URL?
【发布时间】:2013-08-17 11:08:32
【问题描述】:

我尝试在 google plus 中从 android 应用程序中发布来自服务器的图像和链接 URL。但我不能在 google plus 中发布两者。

我已尝试将此代码发布..

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();`

在这段代码中,我只发布了一张图片,但没有发布 URL。URl 已显示但不可点击。

有人给我解决我的问题..

【问题讨论】:

    标签: android google-plus google-play-services


    【解决方案1】:

    您需要google-play-services_lib 库项目。只需将其导入项目中添加的工作区即可。

    您可以在 .../android-sdk-linux_x86/extras/google/google_play_services/libproject 找到它

    并使用此代码通过 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();
    }
    

    【讨论】:

    • 感谢您的回答,但我已经在使用这个库了。我在 Google plus 上成功分享了 URL,还单独分享了图片,但 URL 直接从其内容中获取图片,但我想与内容 URL 和在 URL 链接上我需要我选择的图片(例如,如果我分享 Play 商店链接,那么在 Google+ 上它将采用 Play 商店的默认图片,我需要在此链接上显示我的图片)....所以请帮助我....
    • 如果我分享 Play 商店链接,那么在 Google+ 上它将采用 Play 商店的默认图片,我需要在此链接上显示我的图片,这可能吗??我不认为这是可能的..
    • 你说得对。。但是用我自己的图片播放商店链接是在谷歌上分享的,这是我的基本要求。所以请有人帮助我..
    • 我也在尝试这段代码..但它不起作用。 Intent shareIntent = new PlusShare.Builder(this) .setType("text/plain") .setText("欢迎使用 Google+ 平台。") .setContentUrl(Uri.parse("developers.google.com/+/")) .getIntent(); startActivityForResult (shareIntent, 0); 这只是分享一个链接...
    • 嗨@CapDroid,在此代码中使用了意图;这意味着如果设备上没有安装 Google+ 应用程序,那么这将不起作用。但是我们可以在没有这种依赖的情况下共享图像吗?我想在 G+ 上与文本共享图像,但不应该有这样的依赖。我还在这里发布了关于 SO 的问题....如果你能帮助我,那对我来说非常好..stackoverflow.com/questions/18955084/…
    【解决方案2】:

    解决方案是分享一张图片并在随附的文本中提供 URL。请参阅 PlusShare 文档:

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

    上面写着:当您将媒体分享到 Google+ 时,您也不能使用 setContentUrl 方法。如果您想在帖子中包含一个包含媒体的 URL,您应该将该 URL 附加到 setText() 方法中的预填充文本中。

    【讨论】:

      【解决方案3】:

      .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);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-09-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多