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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:10:46+00:00 2026-06-12T08:10:46+00:00

Here is my onCreate() method. I am trying to pass a variable from one

  • 0

Here is my onCreate() method. I am trying to pass a variable from one intent to this intent. That works fine. When I press back button and go back to previous intent to change the value, then the application crashes. And also when I change the orientation, the application crashes. I am getting “Nullpointer exception” at the pp.getData() method. It passes null argument into the function. How can I overcome this? do I need to add any other details?

public void onCreate(Bundle savedInstanceState) {

    // get intent data
    Intent i = getIntent();

    setQuery(i.getExtras().getString("query"));
    Log.v("query:", getQuery());

    userquery = getQuery();

    super.onCreate(savedInstanceState);
    setContentView(R.layout.product_view_layout);

    try {
        pp = new Parser(userquery);
        productData = pp.getData(asynctask, userquery);
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    mProductViewPagerAdapter = new ProductViewPagerAdapter(
            getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mProductViewPagerAdapter);

}
  • 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-12T08:10:48+00:00Added an answer on June 12, 2026 at 8:10 am

    If the “query” extra doesn’t exist in the Intent then it will return null. You should perform a null check to make sure you don’t get nullPointerExceptions.

    String query = i.getExtras().getString("query"));
    
    if(query == null) {
        setQuery("");
    }
    else {
        setQuery(query);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the code in a function I'm trying to revise. This example works
im trying to setup two listeners for one button. Here is my code: This
I'm trying to run this piece of code inside my onCreate method as an
Here is the code im trying to call inside onCreate() _t = new TheThread(this);
Here's what I'm trying to do: - Retrieve a Map of key-value pairs from
In the onCreate() method, is there a way to reload URL? I am trying
I am trying to pass data through my Intent into the next activity so
So, I have my onCreate method here for populating a ListView with user installed
I'm trying to pull a value from a name in a JSONbject that is
Here I am trying to retrieve the response from the server and display it,

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.