Skip to content

Instantly share code, notes, and snippets.

@andreban
Created December 16, 2015 15:10
Show Gist options
  • Save andreban/ccccade793f63ace207b to your computer and use it in GitHub Desktop.
Save andreban/ccccade793f63ace207b to your computer and use it in GitHub Desktop.
public class CopyLinkBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Uri uri = intent.getData();
if (uri != null) {
ClipboardManager clipboardManager =
(ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clipData = ClipData.newUri(null, uri.toString(), uri);
clipboardManager.setPrimaryClip(clipData);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment