Copy with clipboard manager that supports old and new android versions?
<p>I'm trying to copy text programatically on android, the most voted answer on another question provided these lines but when using them I get error: Class requires API level 11 (current min is 8):</p>

<pre><code>    ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
    ClipData clip = ClipData.newPlainText("label", "Text to copy");
    clipboard.setPrimaryClip(clip);
</code></pre>

<p>I copied the lines directly from the question. After trying with
<code>import android.content.ClipboardManager;</code> I tested <code>import android.text.ClipboardManager;</code> and but it produced an error too <code>The method setPrimaryClip(ClipData) is undefined for the type ClipboardManager</code> plus warnings about ClipboardManager being deprecated.</p>

<p>My app that supports Android 2.2 (API 8 I think) onwards, how can I copy text so it works on all versions of android?</p>
