1

Hello everyone, I need to take parameter id = 55 from this picture, does anyone know how to do that? Thanks!!

System.out.println(voznja.toString());

enter image description here

When I try to log in console, I always get the error that object reference is null.

Reema Q Khan
  • 878
  • 1
  • 7
  • 20

3 Answers3

1

When you call extras.getString("voznja") it returns null because voznja is not a String. Its class is Voznja so you have to write your code like this:

Voznja voznja = (Voznja) extras.getSerializableExtra("voznja");

Now you can get the id by this line:

voznja.get("id");
Litva Nick
  • 483
  • 8
  • 11
  • https://stackoverflow.com/questions/65994815/debugger-doesnt-enter-into-the-onpostexecute-method-in-android Please take a look a this question, i need help here. Thanks – Nikola Stankovic Feb 02 '21 at 10:08
  • Oh, I don't think I can help here. You can search for some information here: https://stackoverflow.com/questions/3606505/onpostexecute-not-called-after-completion-asynctask – Litva Nick Feb 02 '21 at 16:44
0

I think that the id you are trying to read is in an object. I would first suggest using : voznja = extras.getSerializableExtra("voznja")
Then, I would use this to extract the id from the object :
voznja.get(0);
let me know if that helps

0

If your class implements Parcelable use:

Voznja voznja = extras.getParcelableExtra("voznja");

And if it implements Serializable use:

Voznja voznja = extras.getSerializableExtra("voznja");

And then you could get the id from your object.

Stoyan Milev
  • 725
  • 4
  • 17