The clipboard code that works for API levels < 11 crashes on devices with API levels >= 11.
The clipboard code that work for API level >= 11 crashes on devices with API levels < 11.
I can not compile code for both versions because they have conflicting import requirements.
One needs:
import android.text.ClipboardManager;
while the other needs:
import android.content.ClipboardManager;
Surely there is a way write some code that will work on both sides of API level 11. I just can’t figure it out.
***Edited (Since I can’t answer my own question) *******
I found the problem. The exception message says, “Can’t create handler inside a thread that has not called Looper.prepare().”
Apparently I have to jump through some more hoops since I am executing this code from an Async task.
This sample project works quite nicely on API levels before and after 11. I just retested it on Android 2.3 (Nexus One) and Android 4.0 (Nexus S).
That is not surprising. If you are referring to classes or methods that do not exist in older versions of Android, you will get a
VerifyErroror similar crashes.Not really.
That works on all API levels.
That was added to API Level 11. If your app will only run on API Level 11 or higher, use this class (method signatures are all the same IIRC).