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 8575245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:38:59+00:00 2026-06-11T19:38:59+00:00

I have and Intent and I pass, from the MainActivity, two ArrayLists of Parcelables

  • 0

I have and Intent and I pass, from the MainActivity, two ArrayLists of Parcelables to a “FormActivity”, that receives the ArrayLists perfeclty (using startActivityForResult), returns perfectly the data gathered throught the form.

The problem is that, if I click the button to open again the FormActivity, the two ArrayLists are not sent again, and I get a NullPointerException.

Have anyone ever seen this?

Thank you.

MainActivity code:

 public void insertProductButtonClicked(View view){
    Intent addProductIntent = new Intent(getBaseContext(), AddProductActivity.class);
    addProductIntent.removeExtra("consumers");
    addProductIntent.removeExtra("products");
    addProductIntent.putParcelableArrayListExtra("consumers", consumers);
    addProductIntent.putParcelableArrayListExtra("products", products);
    startActivityForResult(addProductIntent, MyActivities.ACTIVITY_ADD_PRODUCT);
}

AddProductActivity code (“FormActivity”):

    Intent intent = new Intent();
intent.putExtra("productName", productNameEditText.getText().toString());
intent.putExtra("productPrice", Double.valueOf(productPriceEditText.getText().toString()));

SparseBooleanArray checkedItems = consumersListView.getCheckedItemPositions();
ArrayList<Integer> consumersToAdd = new ArrayList<Integer>();
for (int i = 0; i < consumers.size(); i++) {
    if (checkedItems.get(i)){
        consumersToAdd.add(consumers.get(i).getId());
    }
}

intent.putIntegerArrayListExtra("productConsumers", consumersToAdd);
setResult(Activity.RESULT_OK, intent);
finish();
  • 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-11T19:39:00+00:00Added an answer on June 11, 2026 at 7:39 pm

    You can declare your ArrayList as a static, check below…

    public static ArrayList<String> array = new ArrayList<String>(); 
    

    By doing this you can access your ArrayList from anywhere by type

    activity_name.array;
    

    where activity_name is the activity or class in which you declare the static ArrayList.

    Good luck.

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

Sidebar

Related Questions

I am using XML parser.In that i have to pass one id from one
I'm trying to pass an int between two classes using a bundle. I have
I want to get all the Applications that have intentlisteners to Intent.CATEGORY_HOME so basically
I have a Service that sends an Intent to my Activity every 0.1 seconds.
I'm trying to pass a bundle of two values from a started class to
I have some images that I loaded from a remote source stored in Bitmap
i have two Activity in this i take pixels of image from one activity
I have two activities, NewTransferMyOwn.java and FromAccount.java When I go from NewTransferMyOwn.java to FromAccount.java,
I have two activities in which I need to pass an object array between
I have a problem(again)...now i want to pass a String from one Activity to

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.