0

I want to make an option like google translate have, when a user copies a text from anywhere in the mobile, a floating button comes for 5 seconds. When the user clicks on that floating button, the copied text is translated into a small window.

Like this

So my question is, how to make above floating button when user copy text from anywhere in mobile?

Please help me to make that...

It is possible by clipboard manager of android but tell me all process please...

Jenea Vranceanu
  • 4,530
  • 2
  • 18
  • 34
  • You won't be able to do it unless your app is a keyboard (which google keyboard shown in your screen is), see https://stackoverflow.com/questions/59863667/cant-get-clipboard-information-on-android-10 – Pawel Jun 22 '20 at 14:36
  • How it will work in background. `clipboard = (ClipboardManager)getSystemService(CLIPBOARD_SERVICE); clipboard.addPrimaryClipChangedListener(new ClipboardManager.OnPrimaryClipChangedListener() { @Override public void onPrimaryClipChanged() { } }); ` This method is working but how it will work in background because it works only when untill my app is not dismiss.When my app stop then it not works properly. – Vipin Dhiman Jun 30 '20 at 14:47
  • If your app is not an input method (like a keyboard) this listener is muted while your app is in the background due to security reasons. In your screen shot sample it works because google keyboard is an input method listening for clipboard. – Pawel Jun 30 '20 at 15:38
  • [Create input method](https://developer.android.com/guide/topics/text/creating-input-method) it will help me or not? or is another way which will work in background of app? – Vipin Dhiman Jul 01 '20 at 02:08
  • Your app would need to be a full fledged input method (like a soft keyboard) and user has to select it as the default (so it pops up whenever he tries to input text anywhere) - I assume neither of those things are happening. – Pawel Jul 01 '20 at 10:22
  • Sir this is possible as you are saying but how is this possible when there is no soft keyboard work means i have a page of screen which has filled by text and there in no Edit Text option then how to do that Copy something and floating window will occur – Vipin Dhiman Jul 03 '20 at 18:08
  • Sir i have read a method copy detection in clipboard action application source code which is possible by accessblity but how to implement that method please give a way. – Vipin Dhiman Jul 03 '20 at 18:15

0 Answers0