Appearance of the application button when text is copied to the clipboard. You can tell what it is and if you can implement it. I would be happy even links to third-party resources.
- 2This button is a new feature of Google Translate. Some service monitors the clipboard and displays the button when content appears - pavlofff
|
1 answer
Perhaps there is a more elegant solution to this problem, but if there is no time or too lazy to look, you can do this:
@Override protected void onResume() { super.onResume(); checkClipboard(); } private void checkClipboard() { ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); String pasteData = ""; if (clipboard.getPrimaryClipDescription().hasMimeType(MIMETYPE_TEXT_PLAIN)) { ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0); pasteData = item.getText(); } if (pasteData.equals("")) showButton(); else hideButton(); } private void showButton() { // показать кнопку, если она еще не показана } private void hideButton() { // скрыть кнопку, если она на еще не скрыта } |
