Reputation: 128
I'm developping an android application, and a need to copy text (from listView item) to the clipboard in order to paste it in an editText.
So copy function looks like :
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText("String to copy");
However, an exception is fired on the first line :
04-12 15:08:59.101:
E/AndroidRuntime(25406): java.lang.NoClassDefFoundError: android.content.ClipboardManager
I've googled it, but i found no working answers.
Thanks for replies
Upvotes: 3
Views: 2723
Reputation: 9117
Check the package of ClipboardManager.
One is from android.text package, and the other is from android.content package.
android.content.ClipboardManager is only available on API level 11 and up. I am guessing thats the reason for this error.
So, you for running your code on older phones, you should use android.text.ClipboardManager
Upvotes: 3