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

  • Home
  • SEARCH
  • 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 6644423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:09:56+00:00 2026-05-26T00:09:56+00:00

I have a problem that I want to set and get Arraylists from a

  • 0

I have a problem that I want to set and get Arraylists from a Serializable class but when we want to set an Arraylist into the Same class it returns NullPointerException, I don’t know why? Please suggest me for right result.

Error Stack:

09-28 11:30:20.422: ERROR/AndroidRuntime(511): java.lang.NullPointerException
09-28 11:30:20.422: ERROR/AndroidRuntime(511):     at com.example.test.Test_serializableActivity.parse_json(Test_serializableActivity.java:88)
09-28 11:30:20.422: ERROR/AndroidRuntime(511):     at com.example.test.Test_serializableActivity$2.run(Test_serializableActivity.java:55)

Code: inserting the values Class

package com.example.test;

import java.util.ArrayList;

import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.json.JSONArray;
import org.json.JSONObject;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.Toast;

public class Test_serializableActivity extends Activity {
    /** Called when the activity is first created. */

    public ArrayList<String> ibx_id = new ArrayList<String>();
    public ArrayList<String> ibx_name = new ArrayList<String>();
    public ArrayList<String> ibx_naturalKey = new ArrayList<String>();
    setIbx ibx;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        HttpPost post = new HttpPost("http://qa.mobile.equinix.com/eqixmobile/siteservice/um/ibx");

        try{
        StringEntity se = new StringEntity("{\"credentials\":{\"username\":\"mobileuser1\",\"password\":\"welcome1\"}}");
        final Service_Call obj = new Service_Call(post, se, "mobileuser1", "welcome1",false);
        final ProgressDialog dialog = ProgressDialog.show(Test_serializableActivity.this, "   EQUINIX                   ", "Loading....   ", true);

        final Handler handler = new Handler() {

           public void handleMessage(Message msg) {

                    Intent intent = new Intent(Test_serializableActivity.this,GetIbx.class);
                    startActivity(intent);
                   dialog.dismiss();

              }
           };

           final Thread checkUpdate = new Thread() {

               public void run() {
                   ibx_name.clear();
                   ibx_name.add("Select");                                    
                   String json_string = obj.call_Service();
                  // new Parse_Json(json_string).parse();
                   parse_json(json_string);
                   handler.sendEmptyMessage(0);
               }
           };
           checkUpdate.start();
        }catch(Exception e)
        {
            e.printStackTrace();
        }
    }

    public void parse_json(String json_string)
    {

        try{
            JSONObject ja = new JSONObject(json_string); 

            JSONArray  jo = ja.getJSONArray("ibx");
            for(int i=0;i<jo.length();i++)
            {
                JSONObject j_data = jo.getJSONObject(i);
                System.out.println("The id is:"+j_data.getString("id"));
                ibx_id.add(j_data.getString("id"));
                System.out.println("The Name is:"+j_data.getString("name"));
                ibx_name.add(j_data.getString("name"));
                System.out.println("The naturalKey is:"+j_data.getString("naturalKey"));
                ibx_naturalKey.add(j_data.getString("naturalKey"));

            }
            }catch(Exception e)
            {
                e.printStackTrace();
            }
            ibx.setId(ibx_id);--------------->**NPE presents**
            ibx.setName(ibx_name);
            ibx.setNaturalKey(ibx_naturalKey);
    }
}

Get the Value Class:

package com.example.test;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

public class GetIbx extends Activity{

    ArrayAdapter<String> statusAdapter;
    Spinner sp_ibx;
    List<String> ibx_list = new ArrayList<String>();
    setIbx ibx;
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.newmain);

        ibx_list = ibx.getName();
        sp_ibx = (Spinner)findViewById(R.id.spinner1);
         statusAdapter = new ArrayAdapter<String>( this,android.R.layout.simple_spinner_item, ibx_list);//Sets an status adapter
            statusAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

            sp_ibx.setAdapter(statusAdapter);
    }

}

Edited: Getter/Setter Class–

package com.example.test;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public abstract class setIbx implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    public List<String> id = new ArrayList<String>();
    public List<String> name = new ArrayList<String>();
    public List<String> naturalKey = new ArrayList<String>();

    public void setId(ArrayList<String> id)
    {
        this.id = id;
    }

    public List<String> getId()
    {
        return id;
    }
    public void setName(ArrayList<String> name)
    {
        this.name = name;
    }
    public List<String> getName()
    {
        return name;
    }
    public void setNaturalKey(ArrayList<String> naturalKey)
    {
        this.naturalKey = naturalKey;
    }
    public List<String> getNaturalKey()
    {
        return naturalKey;
    }

}
  • 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-05-26T00:09:56+00:00Added an answer on May 26, 2026 at 12:09 am

    None of the code you’ve shown ever sets the ibx field in either class. That field will always be null, as far as I can see.

    Note that this isn’t a problem with the ArrayList – it’s the setIbx ibx field which is null. It’s not clear to me what the setIbx class even is, but I would concentrate on working out how you expect this to be non-null rather than the ArrayList fields.

    Might it be as simple as a statement of

    ibx = new setIbx();
    

    in your constructor? (Or in the field declaration?) I’m not an Android developer, so I may well be off-base, but that’s what I think you should be looking at.

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

Sidebar

Related Questions

I have a class that i want to push_back into a deque. The problem
I have a big problem. I want to extract text from html table that
I have a Spring MVC Controller class that needs a property set from a
with my RCP program I have the problem that I want to have more
My problem is that I want to have a tab bar view with its
I have a problem with my site. I want that the shadow stops at
I have problem with fancybox. I want to write a function that will run
My problem is simple: I have a long list of elements that I want
I have a strange problem that the plot overlaps in the graph, but not
I have a problem with my code posted below, set and get methods. I

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.