Skip to content Skip to sidebar Skip to footer

Get String From Bundle Android Returns Null

I want to pass a string from one activity to another, in one of them I wrote public void pdfView(File f) { // f is: /data/data/com.example.iktabClasses/files/fileName.pdf Intent

Solution 1:

try this way

Intentintent=newIntent(first.this, second.class);

Bundlebundle=newBundle();
bundle.putInt("index", index);

intent.putExtras(bundle);startActivity(intent);

then get it as

Bundleb= getIntent().getExtras();
intindex= b.getInt("index");

Solution 2:

in your other activity, instead of using

filename = getIntent().getStringExtra("filename");

try using

filename = b.getString("filename");

That should solve your problem.

Solution 3:

The problem is, in pdfView(), it is written as intent.putExtra("filename", f);.

Try to convert it to toString() (i.e., intent.putExtra("filename", f.toString());

And probably, you can skip sending the Bundle to explicit intent.

Post a Comment for "Get String From Bundle Android Returns Null"