Skip to content

Instantly share code, notes, and snippets.

@ianbarber
Created October 7, 2013 11:05
Show Gist options
  • Save ianbarber/6866090 to your computer and use it in GitHub Desktop.
Save ianbarber/6866090 to your computer and use it in GitHub Desktop.
public void onClickShare(View v) {
Intent photoPicker = new Intent(Intent.ACTION_PICK);
photoPicker.setType("image/*");
startActivityForResult(photoPicker, REQ_SELECT_PHOTO);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == REQ_SELECT_PHOTO) {
if(resultCode == RESULT_OK) {
Uri selectedImage = data.getData();
ContentResolver cr = this.getContentResolver();
String mime = cr.getType(selectedImage);
PlusShare.Builder share = new PlusShare.Builder(this);
share.setText("hello everyone!");
share.addStream(selectedImage);
share.setType(mime);
startActivityForResult(share.getIntent(), REQ_START_SHARE);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment