1

I'm trying to put some info into the clipboard from my gluon-mobile based app and can't seem to figure out how. With Platform.isDesktop() it's easy, the below works fine:

import javafx.scene.input.Clipboard;
import javafx.scene.input.ClipboardContent;

Clipboard clipboard = Clipboard.getSystemClipboard();
ClipboardContent content = new ClipboardContent();
content.putString(addressStr);
content.putHtml("<a href=" + depositAddressUri(address) + ">" + addressStr + "</a>");
clipboard.setContent(content); 

But when Platform.isAndroid() this doesn't work. Any suggestions? Thanks!

Not Mandatory
  • 166
  • 2
  • 7
  • 1
    Check this [tutorial](https://www.tutorialspoint.com/android/android_clipboard.htm) on how to use Clipboard – Shubham Feb 06 '17 at 05:41
  • @Shubham thanks for the link, it looks like the way to do it on android. One other piece of the puzzle is using android apis in a gluon-mobile (javafx ports) app, but this [link](http://stackoverflow.com/questions/31112862/javafx-with-android-api) seems to explain that part. I'll give it a try and report back. – Not Mandatory Feb 07 '17 at 04:30
  • That link is quite outdated now. Check [this](http://stackoverflow.com/questions/41553087/how-to-implemented-in-javafx-gluon-a-button-to-go-to-the-default-send-message-fo) other one instead, as it shows how to extend the latest implementation of the Charm Down plugins – José Pereda Feb 07 '17 at 09:24
  • Thanks Josè! I will try it. – Not Mandatory Feb 08 '17 at 16:14
  • @JoséPereda Is there an update on this question on how to copy to the clipboard on mobile? Most apps, when you hold on a text selection, pop up a menu with options like Copy and Pate (if editable). The closet I found was the Share service, but that's not the same. – user1803551 Jun 23 '22 at 14:19
  • @user1803551 That has nothing to do with this question. Check this post: https://stackoverflow.com/a/40564213/3956070. – José Pereda Jun 23 '22 at 15:03
  • @JoséPereda I'm not looking to create the menu control or hold event, I'm looking to do what this question asks - copy text to the clipboard. I just gave an example of how apps give access to this functionality. – user1803551 Jun 23 '22 at 17:22
  • @user1803551 Indeed, on a mobile app (Android/iOS) you can press/long-press/double tap on any given text, and _sometimes_ it gets selected, and a menu shows up with copy/select/paste options. On a JavaFX app (desktop/mobile), you need to implement it yourself, unless you have a TextField which already has it by default. Typically, Label nodes don't allow selection. Accessing the system clipboard shouldn't be a problem. – José Pereda Jun 23 '22 at 18:02
  • @user1803551 By the way, if you try the [Notes app](https://github.com/gluonhq/gluon-samples/tree/master/notes) on mobile, you will see that the textFields of the Edition view have already the context menu enabled after a long press, without any extra coding as the one I pointed earlier, and copy pasting works just fine. – José Pereda Jun 23 '22 at 18:10
  • @JoséPereda If I just do what the code above does and put a string in the system clipboard, I then go to another app like Gmail or Google Notes, then I can't paste what I just added to the clipboard. If you think it should work (and from what I understand, you do), I will create a reproducible. If this works behinds the scenes in the Notes app (I don't see a call to the clipboard there), it doesn't help me because I can't see how it does it. In my case it's not a text field I copy from, I add clipboard content programatically. – user1803551 Jun 23 '22 at 18:47
  • @user1803551 It is indeed better that you post a new question with what you are already doing and what you want to achieve. – José Pereda Jun 23 '22 at 19:08
  • @JoséPereda There we go https://stackoverflow.com/questions/72737591/copying-to-the-clipboard-does-not-work-on-android. – user1803551 Jun 23 '22 at 23:34

0 Answers0