1
Ask a Question / How to Copy to Clipboard for Android?
« on: November 25, 2016, 10:53:11 pm »
Hello! I'm trying to do what I thought would be a simple feat: copy a text attribute to the clipboard on android (by swiping down).
I've managed to pull it off with a button press on Flash with the following blocks and code snippets:
Import Statements
..do only in flash
......[import flash.desktop.Clipboard;
......import flash.desktop.ClipboardFormats;]
When (x) is pressed
..set FullScoreInfo to (text)
....[do only in Flash]
........[var textToCopy:String = Engine.engine.getGameAttribute("FullScoreInfo");
........Clipboard.generalClipboard.clear();
........Clipboard.generalClipboard.setData(ClipboardFormats.TEXT_FORMAT, textToCopy, false);]
However, Android is proving to be a bit more difficult. This is what I have so far:
Import Statements
..do only on Android
......[import android.os.Environment;
......import android.content.ClipData;
......import android.content.ClipboardManager;
......import android.os.Bundle;]
When the device is swiped (down)
..set FullScoreInfo to (text)
....do only on Android
........[ClipData myClip;
........String text = Engine.engine.getGameAttribute("FullScoreInfo");
........myClip = ClipData.newPlainText("text", text);
........myClipboard.setPrimaryClip(myClip);]
Unfortunately, when I attempt to test the game, I get the following issues:
Send Feedback: Missing ;
from scripts.Design_48_48_SendFeedback
line: 107
columns: 4-12
Send Feedback: Missing ;
from scripts.Design_48_48_SendFeedback
line: 108
columns: 0-6
Send Feedback: Type not found : android.os.Environment
from scripts.Design_48_48_SendFeedback
line: 78
columns: 7-29
Any insight into how this can be done would be greatly appreciated. Thanks!
I've managed to pull it off with a button press on Flash with the following blocks and code snippets:
Import Statements
..do only in flash
......[import flash.desktop.Clipboard;
......import flash.desktop.ClipboardFormats;]
When (x) is pressed
..set FullScoreInfo to (text)
....[do only in Flash]
........[var textToCopy:String = Engine.engine.getGameAttribute("FullScoreInfo");
........Clipboard.generalClipboard.clear();
........Clipboard.generalClipboard.setData(ClipboardFormats.TEXT_FORMAT, textToCopy, false);]
However, Android is proving to be a bit more difficult. This is what I have so far:
Import Statements
..do only on Android
......[import android.os.Environment;
......import android.content.ClipData;
......import android.content.ClipboardManager;
......import android.os.Bundle;]
When the device is swiped (down)
..set FullScoreInfo to (text)
....do only on Android
........[ClipData myClip;
........String text = Engine.engine.getGameAttribute("FullScoreInfo");
........myClip = ClipData.newPlainText("text", text);
........myClipboard.setPrimaryClip(myClip);]
Unfortunately, when I attempt to test the game, I get the following issues:
Send Feedback: Missing ;
from scripts.Design_48_48_SendFeedback
line: 107
columns: 4-12
Send Feedback: Missing ;
from scripts.Design_48_48_SendFeedback
line: 108
columns: 0-6
Send Feedback: Type not found : android.os.Environment
from scripts.Design_48_48_SendFeedback
line: 78
columns: 7-29
Any insight into how this can be done would be greatly appreciated. Thanks!