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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:51:28+00:00 2026-06-15T16:51:28+00:00

I have an activity that allows the user to start a second activity. The

  • 0

I have an activity that allows the user to start a second activity. The second activity has a list of items which I add to an array list. When I return to the previous activity I want to display the size of the array list.

However I am having a problem with onResume(). It is called when my first activity is created and as a result generates an error as the array list does not exist when it is first launched!

onResume():

@Override
protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();
    getIntentData();
    calcSubTotal(orderData);
}

getIntentData():

public void getIntentData(){
    b = new Bundle();
    b = getIntent().getExtras();
    orderData = b.getParcelable("order");
    Toast.makeText(this.getApplicationContext(), orderData.size(), Toast.LENGTH_LONG).show();
}

onCreate() of second activity:

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_starters);
    createTestData();

    b = new Bundle();
    orderData = new MenuItemList();

    adapter = new MenuItemArrayAdapter(this, starters);
    this.setListAdapter(adapter);
}

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {

    Toast.makeText(this.getApplicationContext(), l.getItemAtPosition(position).toString() + " clicked", Toast.LENGTH_LONG).show();
    //add clicked item to orderData....
    MenuItem m = (MenuItem)l.getItemAtPosition(position);
    //create new item
    orderData.add(m);   
}

Any idea how I might be able to control this?

ERROR:

java.lang.RuntimeException: Unable to resume activity {com.example.waitronproto3/com.example.waitronproto3.SectionsActivity}: java.lang.NullPointerException

  • 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-15T16:51:29+00:00Added an answer on June 15, 2026 at 4:51 pm

    However I am having a problem with onResume(). It is called when my first activity is created and as a result generates an error as the array list does not exist when it is first launched!

    I recommend changing getIntentData() to check if the appropriate data exists first:

    public void getIntentData(){
        Intent intent = getIntent();
        if(intent != null && intent.hasExtra("order")) {
            orderData = b.getParcelable("order");
            Toast.makeText(this.getApplicationContext(), orderData.size(), Toast.LENGTH_LONG).show();
            calculateSubTotal(order);
        }
    }
    

    And update onResume():

    @Override
    protected void onResume() {
        super.onResume();
        getIntentData();
    }
    

    (Though you could simply put getIntentData() in onResume() now.)

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

Sidebar

Related Questions

I have an activity that contains several user editable items (an EditText field, RatingBar,
I have an app with : an activity class that allows the user to
I have an activity that opens txt files. And everytime a user wants to
I have an activity powered by a FragmentPagerAdapter which adds fragments as the user
I have an app in the making, and have a Preferences activity which allows
Facebook finally allows to fetch the activity stories of a user (which means these
I have a C# application that allows one user to enter information about customers
I have a Widget i am working on, that allows the user to have
I have a database that allows the user to query for books in the
I have an activity that when users press share on a file it would

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.