This is my code:
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = clipboard.getPrimaryClip();
if(clip!=null) {
ClipData.Item item = clip.getItemAt(0);
String text= item.getText().toString();
Log.d("log_tag", "clipboard: "+text);
}
else {
Log.d("log_tag", "clipboard empty");
}
The problem is, after restarting device, this code says "clipboard empty", even though there is some text in clipboard (And I can verify that by pasting it in other android programs). Then, when I copy something new into android clipboard, my code can see it again and the problem disappears completely!
What can be the reason for this strange behavior?