Dealing with deprecated android.text.ClipboardManager

后端 未结 4 652
情歌与酒
情歌与酒 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:54

    Explicitly:

        @SuppressWarnings("deprecation")
        android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
        clipboard.setText(shareViaSMSBody);
    

    Since this has to keep working on older devices, it is likely that the deprecated code will not be removed from Android.

提交回复
热议问题