3

I am a new android developer. I am trying to make a software which will store password (such as facebook password) of the user. These will be stored and shown as a vertical list view.All these were going properly.

But I want that when anybody will click on one(such as facebook password) of his passwords, that will be copied automatically and pasted on the next clicked edit text field(such as facebook password field) and it can be pasted only once. Once the user paste it, it will be removed from clipboard. But I don't know any method or way to remove the copied data from clipboard after pasting it once by the user. Please help me.

  • I think it is only possible to copy the password to the clipboard: https://developer.android.com/guide/topics/text/copy-paste.html#Copying Pasting into another app must be handled by the user itself. – Christopher Sep 02 '16 at 06:22
  • Thank you very much for your kind response -#CHRISTOPHER. But can I enable an option of pasting the code? Such as through a pop up menu? – Nafiul Islam Sep 02 '16 at 06:31
  • Sorry, I don't catch that. You can copy the password to the clipboard by a button click. In the e.g. FB-app the user can long press on the password edittext and choose PASTE. I don't think it is possible to paste the password directly. – Christopher Sep 02 '16 at 06:34
  • Ow. Thanks. I did not know the long press pasting system of android. Actually I am used to develop android app but not an user of it. I work with my fathers phone. Because I am not 18 yeas old. I am 16. If I disturbed you, please forgive me.I am so much grateful to you. Again thank you very much. -#Christopher – Nafiul Islam Sep 02 '16 at 06:43
  • I want that a password can be pasted only one time. If user want to paste it again , he must copy it again. Is it possible? @Christopher – Nafiul Islam Sep 02 '16 at 08:01

1 Answers1

2

Password normally the copy/paste is not enabled for security reasons.

If you want the onClick code, I believe this was asked before... let me know if wrong.

Check this link.

In the onClick:

ClipboardManager clipboard = (ClipboardManager)getSystemService(CLIPBOARD_SERVICE); 
ClipData clip = ClipData.newPlainText(label, text);
clipboard.setPrimaryClip(clip);
Amg91
  • 165
  • 8
  • 25
  • I have understood but now my question is "can I remove the password from clipboard after pasting it once?" – Nafiul Islam Sep 04 '16 at 02:07
  • You can implement a listener in the EditText were is going to be pasted. Like [this](http://stackoverflow.com/a/7271555/6723193) or [this better](http://stackoverflow.com/a/14981376/6723193). And/or implement your own functions of pasting within the app like [this](http://stackoverflow.com/a/19177510/6723193) and make it work like a `OnPasteListener`. Let me know if helped. – Amg91 Sep 04 '16 at 18:16
  • By the way, for removing the string, you can add empty String into the clipboard. More details [here](http://www.tutorialspoint.com/android/android_clipboard.htm). – Amg91 Sep 04 '16 at 18:31