1

I want to pass a String between two activities, but when I receive the String, I get a null value. I use the same code in other activities and works perfectly. Any suggestion?

First activity:

 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_post);





    Glide.with(PostCarrete.this).load(foto)
            .centerCrop()
            .into(imagen);

    next = (ImageView) findViewById(R.id.next) ;
    next.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            Intent intent = new Intent(PostCarrete.this, Compartir.class);
            intent.putExtra("foton",foto);
            startActivity(intent);

        }
    });
}

Second activity:

    Bundle bundle = getIntent().getExtras();
    foto = bundle.getString("foton");

Here the value of bundle is null, so foto's too

Dani
  • 29
  • 5

1 Answers1

2

I think it should be:

String foto = getIntent().getStringExtra("foton");

because you are sending also as an extra

baskara
  • 1,256
  • 11
  • 7