Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Clipboard Android

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 440
    Comment on it

    Android gives us the facility to copy and paste the data by providing clipboard.

    We can copy text, binary stream, images or other data. Android provides ClipboardManager to handle all this.
    We have to instantiate the object of ClipboardManager by using getSystemSerice() like this.

    ClipboardManager cbm; 
    cbm = (ClipboardManager)getSystemService(CLIPBOARD_SERVICE); 
    

    Copy data:

    ClipData cd; 
    String text = "clipboard message"; 
    cd = ClipData.newPlainText("text", text); 
    cbm.setPrimaryClip(cd); 

    ClipData can use three types of data:
    1. Text
    2. URI
    3. Intent
    Paste data:

    ClipData abc = cbm.getPrimaryClip(); 
    ClipData.Item clipItem = abc.getItemAt(0); 
    String text = clipItem.getText().toString(); 

 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: