Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clearing Clipboard Data in Android

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 ?

like image 494
Radhakrishna Rayidi Avatar asked Mar 20 '13 16:03

Radhakrishna Rayidi


1 Answers

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

ClipboardManager clipBoard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
ClipData data = ClipData.newPlainText("", "");
clipBoard.setPrimaryClip(data);
like image 196
sarnabtech Avatar answered Sep 28 '22 07:09

sarnabtech