Android system Clipboard

Source: Internet
Author: User

Android system Clipboard copy string to system clipping board
/** * Copy Text to Clipboard * * @param text * @return  * *@SuppressWarnings("Deprecation") Public Boolean Copystringtosystem(String text) {Try{if(Android.os.Build.VERSION.SDK_INT > One) {Android.content.ClipboardManager c = (Android.content.ClipboardManager) mcontext.getsystemservice (context.c            Lipboard_service);        C.settext (text); }Else{Android.text.ClipboardManager c = (Android.text.ClipboardManager) mcontext.getsystemservice (context.clipboard            _service);        C.settext (text); }    }Catch(Exception e) {return false; }return true;}
Get the system Clipboard contents
/** * Get Clipboard data * * @return  * *@SuppressWarnings("Deprecation") PublicStringPastestringfromsystem() {String Clipresult =NULL;if(Android.os.Build.VERSION.SDK_INT > One) {Android.content.ClipboardManager c = (Android.content.ClipboardManager) mcontext.getsystemservice (CONTEXT.CLIPB        Oard_service);        Clipdata Primaryclip = C.getprimaryclip (); Item Itemat =NULL;if(Primaryclip! =NULL) {Itemat = Primaryclip.getitemat (0); }if(Itemat! =NULL{String trim = Itemat.gettext (). toString (). Trim ();        Clipresult = Trim; }    }Else{Android.text.ClipboardManager c = (Android.text.ClipboardManager) mcontext.getsystemservice (context.clipboard_ser        VICE); Charsequence text = C.gettext ();if(Text! =NULL) {Clipresult = Text.tostring (). Trim (); }    }returnClipresult;}

Android system Clipboard

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.