title: Why show java.lang.ClassCastException: android.text.SpannableString cannot be cast to java.lang.String?
body: <p>When copying <code>String</code> from any browser page, <code>pasteData</code> works properly.
  However when copying <code>SpannedString</code> from a message sent item editor(field), the application crashes and shows this error message:</p>
  
  <pre><code>java.lang.ClassCastException: android.text.SpannableString cannot be cast to java.lang.String
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>// since the clipboard contains plain text.
  ClipData.Item item = clipBoard.getPrimaryClip().getItemAt(0);
  
  // Gets the clipboard as text.
  String pasteData = new String();
  pasteData = (String) item.getText();
  </code></pre>
  
  <p>where the <code>ClipboardManager</code> instance defined as <code>clipBoard</code>, below:</p>
  
  <pre><code>clipBoard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
  clipBoard.addPrimaryClipChangedListener(new ClipboardListener());
  </code></pre>
  
  <p>All I'm trying to do is use <code>pasteData</code> in <code>String</code> format.
  How to get rid of this error?
  Any help is appreciated.</p>