Created
December 16, 2015 15:10
-
-
Save andreban/ccccade793f63ace207b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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