Skip to content

Instantly share code, notes, and snippets.

@androidcodehunter
Created June 28, 2016 12:37
Show Gist options
  • Save androidcodehunter/0a2dd658257f33daf57420fb932ad768 to your computer and use it in GitHub Desktop.
Save androidcodehunter/0a2dd658257f33daf57420fb932ad768 to your computer and use it in GitHub Desktop.
/**
* Share quote and wait for response. If response -1, the post has been published otherwise not published.
* */
private void shareQuote() {
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
String shareBody = mQuote.getQuote();
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, mQuote.getQuotedBy());
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivityForResult(Intent.createChooser(sharingIntent, "Share via...."), SHARE_REQUEST_CODE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == -1){
// post has been published. Need to call api.
}
if (resultCode == 0){
// post has been canceled. No need to call api.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment