Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to send text in clipboard to EditText box
    text
    copied!<p>My app with two activities is targeted to run on Android 4 or above. <strong>Activity 1</strong> displays a Webview, and <strong>Activity 2</strong> consists of a Listview and an EditText.</p> <p>I would like to programmatically send/export any text copied in the Webview of <strong>Activity 1</strong> to the EditText of <strong>Activity 2</strong> once a button is pressed. </p> <p>To make it clear, my purpose is to create a button to listen to any text copied to clipboard. When the button is pressed, Activity 2 will be called and the text in clipboard will be sent/pasted to the EditText (edtbox) of Activity 2</p> <p>So far, I have applied the following code lines:</p> <p>Activity 1 (on button clicked):</p> <pre><code>ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); clipboard.setText("Text to copy"); clipboard.getText(); Intent i = new Intent(Activity1.this, Activity2.class); Bundle bundle=new Bundle(); bundle.putString("clipboard", "Android"); i.putExtras(bundle); startActivity(i); </code></pre> <p>Activity 2 (under onCreate): </p> <pre><code>Bundle bundle=getIntent().getExtras(); if(bundle !=null) { String name=bundle.getString("clipboard"); EditText edttxt=(EditText)findViewById(R.id.edtbox); edttxt.setText(name); } </code></pre> <p>However, Activity 2 fails to be loaded and Eclipse throws a crash. I guess I haven't sent clipboard text to EditText of Activity 2 but don't know how to do.</p> <p>I wonder whether you guys can help me to solve this problem. Thank you very much in advance.</p> <p>=====</p> <p><strong>UPDATED:</strong></p> <p>Here is the <a href="https://dl.dropbox.com/u/15034088/Others/Temps/logcat.rtf" rel="nofollow">Eclipse LogCat</a>:</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload