Clearing Clipboard Data in Android

☆樱花仙子☆ 提交于 2020-08-18 07:33:19

问题


I'm trying to clear the Clipboard data in android as follow but its not clearing it.

ClipboardManager clipman = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
clipman.setPrimaryClip(null);

Any ideas ?


回答1:


Since API 11 ClipboardManager (as old ClipboardManager class is deprecated.)

ClipboardManager clipBoard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
ClipData data = ClipData.newPlainText("", "");
clipBoard.setPrimaryClip(data);


来源:https://stackoverflow.com/questions/15528653/clearing-clipboard-data-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!