Starting second activity with result on Android

Asked

Viewed 43 times

1

I have two editText that I enter with an in and a calculate button. I would like to present the result in a second activity as soon as I press the calculate button. Could someone help me with this?

  • You need to provide more details on your question. What have you done? What code do you already have? What is the most difficult point to understand?

1 answer

2

The basic model for passing information between Acitivities is this, according to android documentation:

  Intent intent = new Intent(this, OutraActivity.class);
  EditText editText = (EditText) findViewById(R.id.meuEditText);
  String message = editText.getText().toString();
  intent.putExtra("mensagem", message);
  startActivity(intent);

And to take the OutraActivity.class:

Intent intent = getIntent();
String message = intent.getStringExtra("mensagem");

There are more examples in the documentation, take advantage and give a check, is in English but is very dithic.

References for study:

http://www.ideiasprogramadas.com.br/android-passando-dados-telas/

http://developer.android.com/intl/pt-br/training/basics/firstapp/starting-activity.html

How do I pass parameters from the last Fragment to the previous Fragment?

Passing parameters from one Activity to another

Browser other questions tagged

You are not signed in. Login or sign up in order to post.