Last active
August 19, 2018 11:29
-
-
Save bang9/17d35557c3b7943d0dc1cb2eecdef369 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
private void setClipboard(Context context, String text) { | |
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) { | |
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); | |
clipboard.setText(text); | |
} else { | |
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); | |
android.content.ClipData clip = android.content.ClipData.newPlainText("Copied Text", text); | |
clipboard.setPrimaryClip(clip); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment