Putextra in various acitivity

Asked

Viewed 153 times

1

So what I want to do is this. I want to create an image through the app. To create this image, the user will choose 3 images. So to choose them, he will have to go through Activity1 and choose the first image. When he chooses, save the image to a variable or one putextra as I was thinking of doing and opens Activity2. Do it again for Activity3. So. It is possible to have several putextra going from Activity to Activity? These images come from a url stored in the database.

Currently I do with something similar to putextra, but it’s only on an Activity and an image.

Thus:

listView1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            //passa "name" para a classe Detail fazer uma busca;
            intent = new Intent(getContext(), Detail.class);
            intent.putExtra("name", names.get(position));
            intent.putExtra("update", true);
            startActivity(intent);


        }
    });

In the Detail class:

   isUpdate = getIntent().getBooleanExtra("update", false);
    if (isUpdate) {
        databaseAccess.open();
        //aqui pega o "name" e faz uma busca no banco pra trazer a imagem
        data = getIntent().getStringExtra("name");
        getimage = databaseAccess.getImageS(data);

Recovering the image:

 //aqui recupera a imagem e de volta em detail seto ela num 
// imageview via Picasso
public String getImageS(String name) {
    String data = null;
    Cursor cursor = database.rawQuery("SELECT imagem FROM Armas WHERE nome = ?", new String[]{name});
    cursor.moveToFirst();
    while (!cursor.isAfterLast()) {
        data = cursor.getString(0);
        break;
    }
    cursor.close();
    return data;
}
  • Passes the first image to Activity 2. Then, in Activity 2, takes the second image and passes it with the first image to Activity 3. 2 Extras.

  • 1

    Have you ever thought of using Ragment? Maybe it is more advantageous in this situation.

  • @Acklay actually I already use. Has an Activity that shows the frags with the list with the 3 image types I want to match

  • yes it is possible, I have a ki project I did it, but nn with images

No answers

Browser other questions tagged

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