How to post an image on Google Plus in an Android application

I posted the image in my Google Plus account in the Android app. I am taking a picture from a camera and I want to post it to my google + account.

How can i do this?

+3
source share
1 answer

You can specify MediaStore Uri (which looks like content: // media / external / images / media / 42 ) instead of the absolute path in the file system.

Here is an example that takes a picture with a camera and calls the intent ACTION_SEND with this image. If the Google+ application is installed, the user will be able to publish the image that they received from the Google+ application.

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"));
    }
  }
}
+5

All Articles