I know that to send data from one activity to another is as follows:
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 do not want to send data from one activity to another, but to get data and send to another method of the same activity .
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've already tried:
String value = filename;
Intent intent = getIntent();
intent.putExtra("nameFile", value);
startActivity(intent);
But I did not get the value, thank you!