Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
9 Views

Copy & Paste text doesn't work

Hello guys,

I hope someone can help me,

i made an textbased app for android. I want user to push on a button and the text above will be copied and used on the clipboard of the phone.

 

I now have this:

 <button onclick="copyToClipboard('Text that i want to copy on the phone');">Copy text button</button>

 

And this:

 

<script type="text/javascript" language="javascript">
    var isIntel=window.intel&&window.intel.xdk
    // This event handler is fired once the intel libraries are ready
    function onDeviceReady() {
        //hide splash screen now that our app is ready to run
        intel.xdk.device.hideSplashScreen();
        setTimeout(function () {
            $.ui.launch();
        }, 50);
    }
    //initial event handler to detect when intel is ready to roll
    document.addEventListener("intel.xdk.device.ready", onDeviceReady, false);
    
        //Test for javascript interface "intel.xdk.device.copyToClipboard()".
            function copyToClipboard(text){
                intel.xdk.device.copyToClipboard(text);
            }
    
    intel.xdk.device.managePower(true,false);
</script>

 

The device plugin is loaded but the button doesn't work.. I need the buttons on every page so the users can copy my text.

Thankyou :)

Tags (2)
0 Kudos
1 Reply
Highlighted
9 Views

I do not believe the copyToClipboard() function will work in a webview. Your app does not run inside a browser, it runs in a special runtime environement known as a webview. While it appears like a browser, it is not. I suspect you need to find a Cordova plugin that will allow you to copy data into the platform-specific clipboard.

0 Kudos