Android uses clipboard (Clipboardmanager) for data transfer

Source: Internet
Author: User

The first is the call service for the system clipboard:

Clipboardmanager Clipboardmanager=getsystemservice (Context.clipboard_service);

Then it is written, taken out.

It is important to note that before Android version 11, the use of the Clipboard to pass data using the SetText and GetText methods, but after version 11, the two GetText and set methods are discarded, instead of the need to use the Clipdata object to pass the data. Compared with the GetText and SetText methods, the use of Clipdata objects to pass data, more consistent with object-oriented programming thinking, and the type of data can be passed more.

Clipdata cd = Clipdata.newplaintext ("zzzz", basetostring);  Clipboardmanager.setprimaryclip (CD);  

if (Cm.getprimaryclipdescription (). Hasmimetype (Clipdescription.mimetype_text_plain))  {      = cm.getprimaryclip ();       = Cd.getitemat (0);          TxtView.setTextitem.getText (). toString ());  }  

That's o.o for the time being.

Android uses clipboard (Clipboardmanager) for data transfer

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.