Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clipboard not pasting on android #24

Open
marinsokol opened this issue Sep 12, 2016 · 7 comments
Open

Clipboard not pasting on android #24

marinsokol opened this issue Sep 12, 2016 · 7 comments

Comments

@marinsokol
Copy link

Hi,
I have a problem, I am trying to set copy / paste on my android app, but paste is not working when I copy text from any app on my phone and try to paste it in my app. Copy / paste is working when I am in my app and I can paste text, what I copy in my app, in any app on my phone.

Can somebody help me?

this is how I try to paste in my app
window.plugins.clipboard.paste( text => {console.log(text)} );

@ThijmenDF
Copy link

ThijmenDF commented Nov 10, 2016

Hey @marinsokol

First and foremost, you're calling the function incorrectly. You should begin with cordova (or window.cordova) if you're using Cordova. If you use another build system you might have to use window instead.
cordova.plugins.clipboard.paste(function(text) {console.log(text);});
window.plugins.clipboard.paste(function(text) {console.log(text);});

Secondly, are you sure you're calling this function after the deviceready event has fired?

@trinhnguyense
Copy link

When I view log in DDMS, I found this error:
Attempted to send a second callback for ID:
Paste function at native layer is working done, but it can not pass result to web layer.

@gmarkoss
Copy link

I have a very similar issue. My copy/paste functionality works perfect while in app, but if I try to paste some text that was copied in my app, to some other app, it simply doesn't work. The text that was in clipboard before I copied a new one in my app, got pasted.

@sdkcarlos
Copy link

Cannot paste content into my app (copied from another app) with this plugin in Android 6.0

@abelabbesnabi
Copy link

abelabbesnabi commented Jun 9, 2017

I forked the plugin to fix the issue. It has to do with when you copy text from an html page. The mime type is text/html, different from text/plain. The plugin was sending two results in a row which made the call to never comeback even with an error. To get it to work, you can just replace the Clipboard.java class with my class from https://github.com/abelabbesnabi/cordova-plugin-clipboard

@mohamdio
Copy link

@abelabbesnabi 👍
your updated repo working fine and solving this issues, which now i can copy from my app and past in the same app and in others apps also, and can past from other apps, so everything working fine with me now, so what i did which i using ionic 3 :

cordova plugin add https://github.com/abelabbesnabi/cordova-plugin-clipboard --save

and in my ts file from app i did that :

declare var cordova;

@Component({ ....

and inside my file using plugin like that :

cordova.plugins.clipboard.copy(text);

cordova.plugins.clipboard.paste(function (text) { alert(text); });

@mebitek
Copy link

mebitek commented Jul 30, 2018

I have a similar problem:

my app use paste to copy a text as body for mail and/or whatsupp application.
it works well the first time, but i I switch application to copy something, the paste mwthod stop working until I clear the clipboard. I tried to use also the plugin mentioned by @ihadeed,

here a part of code:

 cordova.plugins.clipboard.paste(
      (resolve: string) => {
        console.log(resolve);
        window.open("mailto:" + (email || '') + "?body=" + encodeURIComponent(resolve), "_system");
      }, (reject: string) => {
        console.log(reject);
        window.open("mailto:" + (email || ''), "_system");
      }
    )

note that I tried to use also a var called this.clipboiard initalized in the constructor without success.

any idea in how to solve my problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants