Home > Net >  Problem receiving data through Intent on Android
Problem receiving data through Intent on Android

Time:12-03

It's better to post pictures to show what exactly is going on, okay? The first image shows an object of the Intent class called senderIntent, which will send it to a class called "Resultado". The senderIntent (which is an object of the Intent class) sends the value of the variable email, to another variable also called email:

enter image description here

In the next image, it shows that I created an object of the Intent class called receiverIntent:

enter image description here

Then I created an object of the Bundle class that receives the receiverIntent's getExtras() method. The problem is that the NullPointer Exception error is happening in the line of code: Bundle receiverBundle = receiverIntent.getExtras();

Please what to do to fix?

CodePudding user response:

Generally speaking, do not call Activity methods from a field initializer. Move your getIntent() and getExtras() calls to be inside of onCreate(), after the call to super.onCreate().

  • Related