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 6992069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:35:14+00:00 2026-05-27T19:35:14+00:00

I wrote a code which copies an answer in calculator to clipboard, then calculator

  • 0

I wrote a code which copies an answer in calculator to clipboard, then calculator is closed and another window is opened. The answer should be pasted here using code:

    textOut2= (TextView) findViewById(R.id.etInput1);
    final ClipboardManager clipBoard= (ClipboardManager)getSystemService(CLIPBOARD_SERVICE);
    textOut2.setText(clipBoard.getText());

but it never works. WHere could be a mistake? p.s. I know what text is copied because I can paste using long press but I want to do it automaticaly. And is it possible to give a specific name for a copied text? As it would make it easier to paste words as I have a lot of different TextView’s

  • 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-27T19:35:14+00:00Added an answer on May 27, 2026 at 7:35 pm

    public CharSequence getText ()
    Since: API Level 11
    This method is deprecated.
    Use getPrimaryClip() instead. This retrieves the primary clip and tries to coerce it to a string.

    String textToPaste = null;
    
    ClipboardManager clipboard = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
    
    if (clipboard.hasPrimaryClip()) {
        ClipData clip = clipboard.getPrimaryClip();
    
        // if you need text data only, use:
        if (clip.getDescription().hasMimeType(MIMETYPE_TEXT_PLAIN))
            // WARNING: The item could cantain URI that points to the text data.
            // In this case the getText() returns null and this code fails!
            textToPaste = clip.getItemAt(0).getText().toString();
    
        // or you may coerce the data to the text representation:
        textToPaste = clip.getItemAt(0).coerceToText(this).toString();
    }
    
    if (!TextUtils.isEmpty(textToPaste))
         ((TextView)findViewById(R.id.etInput1)).setText(textToPaste);
    

    You are allowed to add additional ClipData.Item items with text via ClipData.addItem(), but there is no way to discern them.

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

Sidebar

Related Questions

I'm working with the jQuery Validation plugin and I wrote the following code which
I wrote few lines of code which doesn't work correctly. Why? Could sb explain
I recently wrote a piece of code which did SomeClass someObject; mysqlpp::StoreQueryResult result =
I have been refactoring throwaway code which I wrote some years ago in a
I wrote a code sometime ago in which the object of ResultSet class res
I wrote a batch script which recursively updates my source code against the company's
i wrote a little addin, which does some formatting of my C# code. in
i'm using DbSimple, but there is some code which i could write into another
I'm in front of a piece of code, which copies a file to a
I wrote one script which gets an image url through JSONP, and then I

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.