Issue
Create a standard mobile application with this view:
public class DebugView extends View {
ListView<String> console = new ListView<>();
private DebugView() {
setCenter(console);
console.getItems().add("A");
console.getItems().add("A2");
console.getItems().add("A3");
console.getItems().add("A4");
var copyButton = new Button("Copy");
copyButton.setOnAction(e -> {
String log = console.getItems().stream().collect(Collectors.joining(System.lineSeparator()));
var content = new ClipboardContent();
content.putString(log);
Clipboard.getSystemClipboard().setContent(content);
var message = new Toast("Copied to clipboard");
message.show();
});
setBottom(copyButton);
}
}
Run it on desktop and press the Copy button, you can paste the contents into a text editor.
Run it on Android and press the Copy button, you can't paste the contents into another app, like Gmail. Your previous copied content (if exists) will be pasted, so it appears that nothing is added to the clipboard, or that the clipboard is not available.
How to make Clipboard
work on mobile?
Using
<javafx-maven-plugin-version>0.0.8</javafx-maven-plugin-version>
<gluonfx-maven-plugin-version>1.0.14</gluonfx-maven-plugin-version>
<java-version>17</java-version>
<javafx-version>18.0.1</javafx-version>
<charm-version>6.1.0</charm-version>
<attach-version>4.0.14-SNAPSHOT</attach-version>
and graalvm-svm-java17-linux-gluon-22.1.0.1-Final
Solution
The version of Attach 4.0.14-SNAPSHOT
did not support Android clipboard. Version 4.0.15-SNAPSHOT
added the functionality and 4.0.15
has been released with this support.
Answered By - user1803551
Answer Checked By - Mary Flores (JavaFixing Volunteer)