2
I know that to send data from one activity to another is the following:
String value = filename;
Intent intent = new Intent(getApplicationContext(), ReceberNome.class);
intent.putExtra("nameFile", value);
startActivity(intent);
And to receive:
String value = null;
Bundle bundle = getIntent().getExtras();
if (bundle != null){
value = bundle.getString("namefile");
It turns out that I nay I want to send data of a activity to another, and yes take dice deposited in a method and send to another the Activity method.
private void PegarNome(){
//Aqui eu consigo um valor onde não posso chamar no outro método, que é o filename
String value = filename;
Intent intent = new Intent(getApplicationContext(), ReceberNome.class);
intent.putExtra("nameFile", value);
startActivity(intent);
}
private void ReceberNome(){
//Aqui quero receber o filename que é obtido somente no método PegarNome()
}
To send I already tried:
String value = filename;
Intent intent = getIntent();
intent.putExtra("nameFile", value);
startActivity(intent);
But I didn’t get the value, thank you very much!
Thanks a lot bro, but what about Intent? In this code he keeps sending the data to another activity. How do you do with this part: Intent Intent = new Intent (getApplicationContext(), Payname.class);?
– Tech Positivo
If you are in the same Activity, you do not need to start an Intent, just call the method and retrieve the variable value.
– Tiago S
Exactly. Thank you very much ;)
– Tech Positivo