isep
isep

Reputation: 713

Callback from chooser

I just started implementing a share functionality but was wondering if its possible to tell how my content was shared (facebook/twitter/text/etc) without writing my own implementation of chooser. My initial guess was to use startActivityForResult when launching the chooser but haven't managed to figure out which requestcode to use.

public void share(String subject,String text) {
 final Intent intent = new Intent(Intent.ACTION_SEND);
 intent.setType("text/plain");
 intent.putExtra(Intent.EXTRA_SUBJECT, subject);
 intent.putExtra(Intent.EXTRA_TEXT, text);
 startActivity(Intent.createChooser(intent, getString(R.string.share)));
}

Any help would be greatly appreciated! :)

Upvotes: 0

Views: 3117

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007554

My initial guess was to use startActivityForResult when launching the chooser but haven't managed to figure out which requestcode to use.

That will not work reliably. ~99% of activities are not set up to work with startActivityForResult.

I just started implementing a share functionality but was wondering if its possible to tell how my content was shared (facebook/twitter/text/etc) without writing my own implementation of chooser

Sorry, you will need to write your own chooser for this.

Upvotes: 3

Related Questions