[英]How to post an image on Google Plus in an Android Application
I have post an image to Google Plus account in android application. 我已在Android应用程序中将图像发布到Google Plus帐户。 I take a picture from camera and i want to post it on my google+ account.
我从相机拍照,我想在我的谷歌+帐户上发布。
How can i do it ? 我该怎么做 ?
You can specify the MediaStore Uri (which looks like content://media/external/images/media/42 ) instead of the absolute path on the file system. 您可以指定MediaStore Uri(看起来像内容:// media / external / images / media / 42 )而不是文件系统上的绝对路径。
Here's an example that takes an picture with the camera, and fires the ACTION_SEND intent with that image. 这是一个用相机拍照的例子,用该图像激发ACTION_SEND意图。 If the Google+ app is installed, the user will be able to post the image they took from the Google+ app.
如果已安装Google+应用,则用户可以发布他们从Google+应用中拍摄的图片。
public class MyActivity extends Activity {
...
static final int IMAGE_REQUEST = 0;
protected void pickImage() {
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, IMAGE_REQUEST);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == IMAGE_REQUEST) {
Uri uri = data.getData();
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/png");
// uri looks like content://media/external/images/media/42
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(i , "Share"));
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.