1

Somehow I've seen an application that can add Clipboard option to share options.

Something like this screenshot

How can I do that?

I tried to add extra intent, but the additional intent didn't show up

Intent intent = new Intent();
    intent.setAction(Intent.ACTION_SEND);
    intent.putExtra(Intent.EXTRA_TEXT, "Extra Text");
    intent.setType("text/plain");

    Intent clipboardIntent = new Intent();
    clipboardIntent.putExtra(Intent.EXTRA_TEXT, "Extra Text");
    clipboardIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject");

    Intent chooserIntent = Intent.createChooser(intent, "Chooser Title");
    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { clipboardIntent });
    startActivity(chooserIntent);

Thank you :D

1 Answers1

1
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); 
clipboard.setText("Text to copy");

Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, "Extra Text"+clipboard.getText());
intent.setType("text/plain");



Intent chooserIntent = Intent.createChooser(intent, "Chooser Title");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { clipboardIntent });
startActivity(chooserIntent);
  • the clipbaord has to be installed for this .share intent shows all the apps which have intent filter – Harsh Dev Chandel May 08 '13 at 13:50
  • Thanks... But I've tried that. The problem is as long as the application is installed the clipboard selection will still showed up even if the application is closed. I've tried to create the intent filter programmatically so I can unregister the receiver, but the selection won't show up. – Sinned Angel May 13 '13 at 07:04