Android Bundle 空指针

标签 android

在我的 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/

相关文章:

android - 如何检查有多少用户已更新到 Google Analytics 中的新版本?

java - 卡在 AVD 中运行 android 应用程序

android - picasso 自动旋转从相机拍摄的照片,但不旋转从互联网下载的图像

android - 基于 firebase 的移动应用数据服务器设计

java - 安卓工作室 : Text cursor disappears/gone after open some other class or pasting text in different classes

Android Studio 按钮定位

android - 使用 ProGuard 值得这么麻烦吗?

android - Holo 主题在启动画面上不起作用...应用程序崩溃

java - Intent 不提取额外的

android - 一些奥利奥设备没有收到推送通知