2

I want to create an intent choose to show only one option (copy to clipboard), but when I do it, The intent is automatically started (copied to clipboard) and no chooser is displayed. here is my code:

Intent copyToClipboard = new Intent(activity, ShareToClipboardActivity.class);
copyToClipboard.putExtra(Intent.EXTRA_TEXT, entry.getEntryShareLink());
LabeledIntent labeledCopyToClipboard = new LabeledIntent(copyToClipboard, activity.getPackageName(), "Copy!", 0);
List<LabeledIntent> intentList = new ArrayList<>();
intentList.add(new LabeledIntent(labeledCopyToClipboard, activity.getPackageName(), "Copy to clipboard", R.drawable.ic_content_copy_gray_24dp));

Intent chooserIntent = Intent.createChooser(new LabeledIntent(labeledCopyToClipboard, activity.getPackageName(), "Copy to clipboard", R.drawable.ic_content_copy_gray_24dp), "Share entry");
activity.startActivity(chooserIntent);

can someone please advise?

roeiki11
  • 279
  • 1
  • 3
  • 12

1 Answers1

0

something is fishy! am i being paranoid or you defined nested intent in these two line of your code? are this necessary?

LabeledIntent labeledCopyToClipboard = new LabeledIntent(copyToClipboard, activity.getPackageName(), "Copy!", 0);

Intent chooserIntent = Intent.createChooser(new LabeledIntent(labeledCopyToClipboard, activity.getPackageName(), "Copy to clipboard", R.drawable.ic_content_copy_gray_24dp), "Share entry");
Mehran Zamani
  • 831
  • 9
  • 31