Dealing with deprecated android.text.ClipboardManager

后端 未结 4 664
情歌与酒
情歌与酒 2021-02-07 13:09

android.text.ClipboardManager was deprecated since API level 11, and replaced with android.content.ClipboardManager (source).

How do I write c

4条回答
  •  青春惊慌失措
    2021-02-07 13:49

    If you are still supporting < SDK 11 you are doing too much work. Set min to 15 and use this code:

     ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); 
     ClipData clip = ClipData.newPlainText("label for text", "text to copy");
     clipboard.setPrimaryClip(clip);
    

提交回复
热议问题