Kartik Bhatt
Kartik Bhatt

Reputation: 924

Get sharing status of content in android

I want to share content in Android, so I use following code for sharing:

Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(
  android.content.Intent.EXTRA_TEXT, message);
startActivityForResult(Intent.createChooser(
  sharingIntent, "Share using"), 1000);

In onActivityResult(), I write following code:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);
  Log.d("TAG", "::onActivityResult:" + "requestCode:" + requestCode
    + "resultCode:" + resultCode + "Data:" + data);
}

When onActivityResult() is called, resultCode is always 0.

Upvotes: 0

Views: 936

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006654

That is because ACTION_SEND is not set up for use with startActivityForResult(). No implementer of ACTION_SEND needs to call setResult(), and therefore few, if any, will.

Any Intent action whose documentation says "Output: nothing" is not designed for use with startActivityForResult().

Upvotes: 1

Related Questions