When copying a String from any browser page, pasteData works correctly. However, when copying a SpannedString from the sent messages editor (fields), the application crashes and displays this error message:
java.lang.ClassCastException: android.text.SpannableString cannot be cast to java.lang.String
My code is:
where the ClipboardManager instance is defined as clipBoard , below:
clipBoard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE); clipBoard.addPrimaryClipChangedListener(new ClipboardListener());
All I'm trying to do is use pasteData in String format. How to get rid of this error? Any help is appreciated.
java android string clipboard spannablestring
user4356416
source share