Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Copy Text from android application

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 241
    Comment on it

    I am writing code to copy specific content on any event.
    Android provides clipboard-based framework to do this task.
    Clipboard is represented by ClipboardManager class. To instantiate it, we need to call getSystemService(CLIPBOARD_SERVICE)

    Then we create ClipData object to add data to the clipboard.
    We have some ClipData methods like newPlainText(label, text),newUri(resolver, label, URI) and newIntent(label, intent)

    Below is the codeS

    String mWorkingUrl = mUrl+"/"+mWebUserName;
    
        android.content.ClipboardManager clipboard = (android.content.ClipboardManager)this.getSystemService(Context.CLIPBOARD_SERVICE);
        android.content.ClipData clip = android.content.ClipData.newPlainText("Copy",mWorkingUrl);
        Toast.makeText(getApplicationContext(), "Copied", Toast.LENGTH_SHORT).show();
        clipboard.setPrimaryClip(clip);

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: