Home > other >  How can I transfer data new intent
How can I transfer data new intent

Time:07-18

my Onbindview holder

    Glide.with(holder.t1.getContext())
            .load("http://example/example/images/"  data.get(position).getImage()).into(holder.img);
}

And my interface

itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (iOtobusSaatleriInterface != null){
                    int position = getAdapterPosition();
                    if (position != RecyclerView.NO_POSITION);
                    iOtobusSaatleriInterface.onItemClick(position);
                    Intent intent = new Intent(context,deneme.class);
                    intent.putExtra("name",data.get(position).getName());
                    intent.putExtra("resim", String.valueOf(Glide.with(itemView)
                            .load("http://example/example/images/"  data.get(position).getImage())));
                    
                    context.startActivity(intent);
                }
            }
        });

my new activity

Intent intent = getIntent();
    String name = intent.getStringExtra("name");
    int goruntu = intent.getIntExtra("resim",0);
    imageView.setImageResource(goruntu);
    textView.setText(name);

finally my photo is not coming. I just can't get the image data in the new activity. This data is registered in mysql and I am pulling from the directory with retrofit.

CodePudding user response:

You can pass the image as a string from screen A to screen B.

CodePudding user response:

The batter way is to pass full URL in intent as String and receive it on another Activity.

Intent intent = new Intent(context,deneme.class);
                    intent.putExtra("name",data.get(position).getName());
                    intent.putExtra("resim","YOUR_FULL_URL");

At Another Activity

    Intent intent = getIntent();
        String name = intent.getStringExtra("name");
        String goruntu = intent.getStringExtra("resim");
    
String.valueOf(Glide.with(imageView)
                            .load(goruntu)
        textView.setText(name);

CodePudding user response:

Without knowing more about why you are trying to send a raster image over IPC between activities, I think the best advice I can give you is to not try to do that.

Instead, simply send the URL in the intent and have Activity 2 use glide to load and display the image.

  • Related