简体   繁体   中英

Problem receiving data through Intent on Android

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:

在此处输入图像描述

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

在此处输入图像描述

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?

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() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM