I have a button, by clicking on which the user shares a link in applications, etc. Here is her code:

private void shareURL() { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.web_share_end) + browser.getUrl()); startActivity(Intent.createChooser(shareIntent, getResources() .getString(R.string.share))); } 

How to make the link just copied to the clipboard?

    1 answer 1

     String url = "http://google.com"; ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText(label, url); clipboard.setPrimaryClip(clip);