Honeycomb deprecated android.text.ClipboardManager
and introduced android.content.ClipboardManager
.
You should check whether android.os.Build.VERSION.SDK_INT
is at least android.os.Build.VERSION_CODES.HONEYCOMB
and therefore use one or the other.
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB)
{
// Old clibpoard
android.text.ClipboardManager clipboard = (android.text.ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText("the text");
}
else
{
android.content.ClipboardManager clipboard = (android.content.ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
android.content.ClipData clipData = android.content.ClipData.newPlainText("PlainText", "the text");
clipboard.setPrimaryClip(clipData);
}