0

I am using this code to share link in android app.

Intent i=new Intent(android.content.Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(android.content.Intent.EXTRA_SUBJECT,"Subject test");
i.putExtra(android.content.Intent.EXTRA_TEXT, "extra text that you want to put");
startActivity(Intent.createChooser(i,"Share via"));

But i want to add cutom intent option in dialoag box.

If i have twitter and facebook app in my phone, then above code give me share option 1) Twitter 2) Facebook 3) Bluetooth(if phn supported)

Also with this I want to add

4) Commnets (on comments click user will go my Comment activity)

I want to make share like this. Can anyone help. Thanks in advance.

michaelmsm89
  • 475
  • 7
  • 20
dnana
  • 171
  • 1
  • 3
  • 14

1 Answers1

0

You are creating a chooser. It contains all intents that reply to ACTION_SEND text/plain.

To have your comment activity in that list, you need make an intent-filter in your manifest matching that actions for your comment Activity.

Alternatively (and moreeasily, too), if you don't want your Comment activity to respond to external ACTION_SEND text/plain, you can use the response given to this question : Custom filtering of intent chooser based on installed Android package name : Add a Intent.EXTRA_INITIAL_INTENTS extra to the intent.

Community
  • 1
  • 1
njzk2
  • 38,969
  • 7
  • 69
  • 107