My app with two activities is targeted to run on Android 4 or above. Activity 1 displays a Webview, and Activity 2 consists of a Listview and an EditText.
I would like to programmatically send/export any text copied in the Webview of Activity 1 to the EditText of Activity 2 once a button is pressed.
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
So far, I have applied the following code lines:
Activity 1 (on button clicked):
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);
Activity 2 (under onCreate):
Bundle bundle=getIntent().getExtras();
if(bundle !=null)
{
String name=bundle.getString("clipboard");
EditText edttxt=(EditText)findViewById(R.id.edtbox);
edttxt.setText(name);
}
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.
I wonder whether you guys can help me to solve this problem. Thank you very much in advance.
=====
UPDATED:
Here is the Eclipse LogCat: