Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7177419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:42:35+00:00 2026-05-28T16:42:35+00:00

The clipboard code that works for API levels < 11 crashes on devices with

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:42:36+00:00Added an answer on May 28, 2026 at 4:42 pm

    The clipboard code that works for API levels < 11 crashes on devices with API levels >= 11.

    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).

    The clipboard code that work for API level >= 11 crashes on devices with API levels < 11.

    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 VerifyError or similar crashes.

    I can not compile code for both versions because they have conflicting import requirements.

    Not really.

    One needs: import android.text.ClipboardManager;

    That works on all API levels.

    while the other needs: import android.content.ClipboardManager;

    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).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying do do a simple StringReplace, clipboard, clipboard, \, /, All That code works
I'm using http://www.steamdev.com/zclip/#usage to copy some text to the clipboard and that code is
I'm trying to code up an Emacs script that has to manipulate the clipboard
I'm working on a project that's supposed to work on both Windows and Linux
i have a problem using the Catch Clipboard Events code found on this link
I use the ditto clipboard extension when I'm writing code, it's great for copying
Why does the following code sometimes causes an Exception with the contents CLIPBRD_E_CANT_OPEN: Clipboard.SetText(str);
How can you copy text to clipboard using Javascript (or even nicer a jQuery
It's not (visibly) using the clipboard because it doesn't trash the clipboard contents... where
I am using WPF to display the image in the clipboard. This works fine

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.