I want to copy some text in temprory memory :
TextView tv = (int)findViewById(R.id.txt);
String str = tv.getText().toString();
now how an I copy str in clipboard ???
I want to copy some text in temprory memory :
TextView tv = (int)findViewById(R.id.txt);
String str = tv.getText().toString();
now how an I copy str in clipboard ???
Use ClipboardManager
int sdk = android.os.Build.VERSION.SDK_INT;
if(sdk < android.os.Build.VERSION_CODES.HONEYCOMB) {
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText("text to clip");
} else {
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
android.content.ClipData clip = android.content.ClipData.newPlainText("text label","text to clip");
clipboard.setPrimaryClip(clip);
}