Android Studio, how to collect data from other screens and show on the last screen?

1

I have an app with 5 screens,

  • The first screen the basic information of the user where user inserts the information;

  • On the second screen, the information about your interests;

  • On the third screen your goals;

And so by the next, wanted that when he presses on screen 4 the next screen button appears all the information he reported.

    
asked by anonymous 02.06.2016 / 02:01

1 answer

1

There is a library that facilitates the transport of objects between classes.

It's the Parceler !

Here's an example:

Add the following dependencies to your build.gradures :

dependencies {
    …
    compile 'org.parceler:parceler:1.0.4'
    compile 'org.parceler:parceler-api:1.0.4’
}

Sample class with values that we will carry from one Activity to another:

Values.class

import org.parceler.Parcel;
@Parcel
public class Valores {
    String nome;
    String sobrenome;
    Integer idade;
    Boolean masculino;
    String rua;
    String bairro;
}

Shipping :

final Intent intent = new Intent(this, Step1.class);
Valores valores = new Valores();
valores.nome = "Thiago";
valores.sobrenome = "Domacoski";
valores.idade = 32;
intent.putExtra("valores", Parcels.wrap(valores));
startActivity(intent);

Reception :

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_step1);

    if(null != getIntent().getParcelableExtra("valores")){

        Valores valores = Parcels.unwrap(getIntent().getParcelableExtra("valores"));

    }
}
    
02.06.2016 / 13:50