Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear Clipboard on SGS2 (api 10)

I'm using a Samsung Galaxy S2 and tried the following:

import android.text.ClipboardManager;
ClipboardManager clipboard = (ClipboardManager)context.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(null);

and

clipboard.setText("");

It didn't work. Ideas?

like image 225
timothyjc Avatar asked Sep 09 '11 13:09

timothyjc


2 Answers

Their is a bug with the Samsung Galaxy. It doesn't accept setting the clipboard to a blank value. You could try setting it to a space instead.

clipboard.setText(" ");

For further information check this

like image 102
Saqib Razaq Avatar answered Nov 06 '22 02:11

Saqib Razaq


Have you tried .setPrimaryClip(ClipData clip)? The documentation reads:

public void setPrimaryClip (ClipData clip)

Since: API Level 11 Sets the current primary clip on the clipboard. This is the clip that is involved in normal cut and paste operations. Parameters

clip The clipped data item to set.

According to the docs, setText() is deprecated.

I know this question is old, but it's worth a try.

like image 1
Jack Avatar answered Nov 06 '22 00:11

Jack