Murali
Murali

Reputation: 109

Android Bundle NullPointer

In my Android application I want to transfer data between activities; mentioned FirstActivity.class and SecondActivity.class. But in my FirstActivity it is showing a NullPointerException. Can you tell me what's wrong in my class?

FirstActivity.class:

Bundle bundle = getIntent().getExtras();
         fingerPrintID = bundle.getString("ThumbInfo");  

SecondActivity.class:

Bundle bundle = new Bundle();
bundle.putString("ThumbInfo", FingerImageData.toString());  
Intent enroll=new Intent(First.this,Enroll.class);
enroll.putExtras(bundle);
startActivity(enroll);  

Upvotes: 1

Views: 692

Answers (2)

Samir Mangroliya
Samir Mangroliya

Reputation: 40416

Suppose,,,If you pass data from activity1 to activity2::

In activity 1::

            Intent intent = new Intent(activity1.this, activity2.class);
            intent.putExtra("ThumbInfo", thumbInfo);
            startActivity(intent);

In activity 2::(in oncreate method)

            Bundle bundle = getIntent().getExtras();
            String category_name = bundle.getString("ThumbInfo");

Upvotes: 1

Yashwanth Kumar
Yashwanth Kumar

Reputation: 29121

use

enroll.putExtras(bundle);

you have to pass the bundle with the intent.

Upvotes: 0

Related Questions