How can I get a result for an intention to share?

I use the following code to share:

Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_text)); sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); sendIntent.setType("image/png"); startActivityForResult(Intent.createChooser(sendIntent, getResources().getString(R.string.share_via)), REQUEST_SHARE_RESULT); 

And I want to check the result for this intention in my onActivityResult() function. But it always returns Activity.RESULT_CANCELED . Even sharing has been successful. Why???

+4
source share
2 answers

In your child activity, you must call setResult() before calling finish() ; this is how the child returns its result to the parent onActivityResult() method.

-1
source

All Articles