How to get values and play in another class? Android

2

I have the following class:

 public class RetornaUsuarioActivity extends Activity  {    

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    AcessoRest ar = new AcessoRest();
    String chamadaWS;
    chamadaWS = "http://www.cordeiro-it.com.br/SOUPROGRESSO/Ctrl/recuperaUser.php";
    String resultado = ar.chamadaGet(chamadaWS);
    System.out.println(resultado);
    Log.i("JSON:",resultado);

    try {
        // Tratamento de erros
         JSONObject jsonResponse = new JSONObject(resultado);
         JSONArray usuarios = jsonResponse.getJSONArray("usuarios");

         for(int i=0; i < usuarios.length(); i++) {
             JSONObject jsonobject = usuarios.getJSONObject(i);
             String nome = jsonobject.getString("nome");
             String cpf = jsonobject.getString("cpf");

             /*TextView tv = (TextView) findViewById(R.id.txtMessage);
             tv.setText(nome);*/
          }  

    } catch (Exception e) {
        // ERRO
        e.printStackTrace();
        System.out.println("Erro ao retornar dados do usuário");
    }

}

}

How do I get and play the NAME and CPF values that are in that for in another Activity class?

Type I want to get these values to see if the user exists or not, then save to a TXT file.

    
asked by anonymous 22.06.2015 / 20:12

1 answer

2

To send data:

EditText editText1 = (EditText) findViewById(R.id.name);
EditText editText2 = (EditText) findViewById(R.id.ma);
String message = "Oi! " + editText1.getText().toString();
int i = Integer.parseInt(editText2.getText().toString());

Bundle param = new Bundle();
param.putString("greeting",message);
param.putInteger("NumberInteger",i);

Intent intent = new Intent(this, DisplayMessageActivity.class);
intent.putExtras(param);
startActivity(intent);

To receive, then, in the DisplayMessageActivity.java class do:

Intent it = getIntent();
Bundle param = it.getExtras();
String capturedMessage= param.getString("greeting");
Integer captured_I = param.getInteger("NumberInteger");
    
22.06.2015 / 20:46