views:

111

answers:

2

I am displaying search results from a webservice.

What I do is OnCreate I hit the webservice display records, as android supports multitasking. If user opens another screen and after some time comes back to the search results page, the application starts acting crazy....

OnCreate method I load data some thing like :

private void loadData() throws Throwable{
     try {
      jsonArray = JSONService.getJsonArray(getResources().getString(R.string.catJson));
     } catch (Throwable e) {
      Log.e(TAG, e.getMessage());
      throw e;
     }
    }

and then I iterate through json array and change labels value to display result on the screen.

Any ideas how to fix this?

A: 

Yes, please explain our problem better. Are you familiar with the Activity life-cycle? There are several different callbacks that you must manage in order for your concept of multitasking to actually work. Based on the limited info you've provided, I don't think you're saving any of your application state when your Activity loses focus. So your process may be getting shutdown and when you come back, your JSON array is gone. Read this: http://developer.android.com/guide/topics/fundamentals.html#lcycles

Scott Main
A: 

Are you calling the super in your OnCreate?

super.onCreate(savedInstanceState);
lpz