-4

I am working on this code, and get an error, the variable "textoviejo" is returned as null, I would like to know what is wrong here. Thank you

Activity 1

EditText input = (EditText) findViewById(R.id.input); 
startActivityForResult(new Intent(this, Activity2.class), REQUEST_CODE_SEND);
Intent i = new Intent(this, EmoticonActivity.class);   
i.putExtra("textoviejo", input.getText().toString()); 

Activity 2

 Intent intent = new Intent();


    String mensaje = intent.getStringExtra("textoviejo");
    String emoticon = mensaje + ":)";
    intent.putExtra(Extra.EMOTICON, emoticon);
    setResult(RESULT_OK, intent);
    finish();

Result in EditText = null

4

3 回答 3

1

代替

Intent intent = new Intent();

尝试

Intent intent = getIntent();
于 2014-08-01T12:05:09.587 回答
0

你没用过

   Intent intent = getIntent();

然后打电话

  String mensaje = intent.getStringExtra("textoviejo");
于 2014-08-01T12:05:20.947 回答
0

EmoticonActivity.class 是你的 activity2 吗?如果是的话

你做错了,这样做

活动一

EditText input = (EditText) findViewById(R.id.input); 
Intent i = new Intent(this, EmoticonActivity.class);   
i.putExtra("textoviejo", input.getText().toString()); 
startActivityForResult(i, REQUEST_CODE_SEND);
于 2014-08-01T12:07:43.313 回答