Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7764825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:00:56+00:00 2026-06-01T15:00:56+00:00

I am working on an application, and from a list view I create a

  • 0

I am working on an application, and from a list view I create a bundle that includes the item selected and the previous item. What I need to determine is if the previous item actually gets bundled through. If it exists, I want the information, but if it doesn’t exist, then I need to set my text views to reflect that. But I get a null pointer exception if it doesn’t exist when trying to load the receiving activity (the bundling activity does not cause the crash as I found during debugging – I get to the point where I’m testing for the data in the bundle before it crashes). So I’ve included the code from the receiving activity.

    Bundle evmBundle = this.getIntent().getExtras();
    final EVMData evm = (EVMData) evmBundle.getSerializable("evm");

    final Project project = (Project) evmBundle.getSerializable("project");

            if (!evmBundle.getSerializable("prvEVM").equals(null)){
        final EVMData prvEvm = (EVMData) evmBundle.getSerializable("prvEVM");
        edtPrvAC = (TextView) findViewById(R.id.edtPrvEVMAC);
        edtPrvAC.setText(prvEvm.getAc().toString());
    }
    else{
        edtPrvAC = (TextView) findViewById(R.id.edtPrvEVMAC);
        edtPrvAC.setText("0");
    }

I know something is getting passed through in the bundle for “prvEVM” because it showed up as part of the bundle in the debugger.

I also tried pulling it out of the bundle first and then trying to compare it. After pulling it out of the bundle, prvEvm is null (looking at the variables in the debugger), so I thought something like this might work:

     if (!prvEvm.equals(null)){
        edtPrvAC = (TextView) findViewById(R.id.edtPrvEVMAC);
        edtPrvAC.setText(prvEvm.getAc().toString());
    }else{
        edtPrvAC = (TextView) findViewById(R.id.edtPrvEVMAC);
        edtPrvAC.setText("0");
    }

But I get a NullPointerException because prvEvm is Null. So I tried flipping the if test around, but got the same results. I should note that no matter how I set this up, if prvEvm is not null, all configurations here work – the requested data is put in the TextView. Basically, I need to be able to get around this null pointer exception. I know the object is null, I want to test for that so that if it is, that object isn’t used. It will only be null once.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T15:00:57+00:00Added an answer on June 1, 2026 at 3:00 pm

    Don’t use equals(null) as you call a method (equals) on a null object. Instead, compare to null:

    if (prvEvm != null){
    

    besides, equals(null) always returns false.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a contact list application I need to create 2 tables
I am working on an application, that converts data from different companies into corresponding
I have been working on a BlackBerry application that consumes web services from ColdFusion
I'm working on an iPhone application that downloads data from a web server and
I am working on an application that pulls information from the internet. The information
I'm currently working on migrating an application from MS-Access to MS SQL Server. In
I'm working with XML data from an application where we get XML like this:
I'm working on an application which has data imported from a foreign (and wholly
My Application was working fine. But as soon as i updated from ADT 16
I'm working on a vb.net application which imports from an Excel spreadsheet. If rdr.HasRows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.