简体   繁体   English

将照片从应用程序共享到Google+

[英]Sharing photos from app to google+

I am trying to share images from my app to social networks. 我试图将图像从我的应用程序共享到社交网络。 I have implemented Facebook and Twitter , but at Google+ , I can't see any way. 我已经实现了FacebookTwitter ,但在Google+ Twitter却看不到任何方法。

I have seen apps like Instagram etc. share images on Google+. 我看到过Instagram等应用程序在Google+ Instagram共享图像。 However, on Google+ developers the only thing that I can find is this: 但是,在Google+开发人员上,我唯一能找到的是:

The latest version of the Google+ Android SDK, including the SDK Tools component (not yet available). 最新版本的Google+ Android SDK,包括SDK Tools组件(尚不可用)。

Can anyone please show me how I can share my images on Google+? 谁能告诉我如何在Google+上分享我的图片?

You can share media (photos and albums) on Google+ with the ACTION_SEND intent. 您可以按ACTION_SEND意图在Google+上共享媒体(照片和相册)。 The media can be specified within the EXTRA_STREAM , and needs to contain the content URI of the media. 可以在EXTRA_STREAM中指定媒体,并且需要包含媒体的内容URI

Here's an example: 这是一个例子:

File file = new File(Environment.getExternalStorageDirectory(),
        MY_PICTURE_FILE_NAME);
String photoUri = MediaStore.Images.Media.insertImage(
        getContentResolver(), file.getAbsolutePath(), null, null);

Intent shareIntent = ShareCompat.IntentBuilder.from(MyActivity.this)
        .setText("Sharing an image on Google!")
        .setType("image/jpeg")
        .setStream(Uri.parse(photoUri))
        .getIntent();
startActivity(shareIntent);
file.delete();

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

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