1

I am having a bit of a problem. I have an activity class that has an inner class that extends AsyncTask. In the onProgressUpdate() I am trying to create a new Intent. When I try to crate the Intent object I get a NullPointerException. This is the line that is causing the exception:

Intent intent = new Intent(OuterClassActivity.this, OuterClassActivity.class);.

The inner class searches a database. When the search is done I call publishProgress() and in onProgressUpdate() is where I am trying to create this intent to start the OuterClassActivity so it can display the results.

I have been searching around for a few hours now and cant find anything. Any help will be greatly appreciated.

1
  • Could you be more specific about why you need to create a new Activity each time publishProgress is called ? May 2, 2012 at 10:48

2 Answers 2

0

Why you use Intent for calling the outerclass? To my understanding, Intent is used to call a different view. Instead call a method that's defined in the outerclass to display the results.

1
  • I placed this method in a separate activity in the same package protected void startOtherActivity() { Intent intent = new Intent(this, RecipeSearchActivity.class); startActivity(intent); } I create an instance of the other activity and call this startOtherActivity() and I still get a NullPointerException at this line Intent intent = new Intent(this, RecipeSearchActivity.class); May 2, 2012 at 3:36
0

Why don't you just update the current view instead of creating a new Activity ? Could you be more specific about why you need to create a new Activity ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.