在我的 Android 应用程序中,我想在 Activity 之间传输数据;提到了FirstActivity.class 和SecondActivity.class。但在我的 FirstActivity 中它显示了一个 NullPointerException
。你能告诉我我类有什么问题吗?
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);
最佳答案
假设,,,如果你将数据从 activity1 传递到 activity2::
在 Activity 1::
Intent intent = new Intent(activity1.this, activity2.class);
intent.putExtra("ThumbInfo", thumbInfo);
startActivity(intent);
在 Activity 2::(在 oncreate 方法中)
Bundle bundle = getIntent().getExtras();
String category_name = bundle.getString("ThumbInfo");
关于Android Bundle 空指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7797811/