pasteboard.paste Android Bug?

No, I don’t need a project, let me just test a bit on my side…

It works on my Android Asus ZenFone without any issues, same as iOS.

Here’s my test code:

[lua]local pasteboard = require( “plugin.pasteboard” )

local function didPaste(e)

    print ("paste type: " … pasteboard.getType())

    print ("paste string: " … tostring(e.string))

end

local function pasteb()

    pasteboard.paste( didPaste )

end

local b = display.newRect( 100, 100, 100, 100 )

b:setFillColor(1,0,0)

b:addEventListener( “tap”, pasteb )

[/lua]

It seems like this issue is only happening with long strings on Android. Shorter ones work, but longer ones with thousands of characters don’t. These long strings can be pasted in other parts of the Android OS, just not in my Corona app.

Are you getting and errors/warnings reported in the logcat?

I finally figured it out. It turns out that on Android, there’s a slight delay when doing pasteboard.paste(). Here’s what I was doing:

[lua]

local pastedText = nil

local function didPaste(e)

       pastedText = tostring(e.string)

end

pasteboard.paste(didPaste)

if (pastedText ~= nil) then

       --Some stuff here

end

[/lua]

The code would jump straight to line 9 before pastedText had a chance to be set to the data from the clipboard. So pastedText was being set correctly, the problem was that it was happening too late since the rest of the code had already run. iOS doesn’t have this problem. I solved it by putting in a small delay before running my if statement at line 9. Works perfectly now! I think you should maybe mention this, since it would seem like something you’d need to use fairly often when working with the clipboard. It took me a while to figure out what was going on, but I’m glad it’s all working now. I’m still not sure why my code from 5 posts up didn’t work. All the code was in a button listener and running on the began phase. Maybe there’s another bug lurking somewhere with pasteboard? I’ve separated it all out now and have it working with my timer delays. Thanks for the help!

Thanks for the info.

I’ll take a look at the Pasteboard code and see if there is anything funky going on.
Cheers

I am having the same issue. What did you do with a timer to fix it? In my situation I am using the string that is in the clipboard be put into a function and then the output is displayed in a textBox. The app works perfectly on iOS and is currently listed on the app store, but the android version is not working correctly.