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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:43:59+00:00 2026-05-13T09:43:59+00:00

Please guide in the following class what I should save in. Please remember I

  • 0

Please guide in the following class what I should save in.

Please remember I am using only one string which is I am retriving from getextra method and there is nothing which I think I should store in the following overridden method.

protected void onSaveInstanceState(Bundle outState) {
    // TODO Auto-generated method stub
    super.onSaveInstanceState(outState);
}

Can you guide me what to store in onsave instance method and what not to?

package com.wozzon.activity;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONObject;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;

import com.wozzon.json.JSONService;
import com.wozzon.model.SearchCriteria;
import com.wozzon.pl.UIFactory;
import com.wozzon.util.Util;
import com.wozzon.util.WLConstants;

public class HomeBrowse extends Activity implements OnItemClickListener{
    private final static String TAG = HomeBrowse.class.getSimpleName();
    private ArrayList<BrowseRow> model=new ArrayList<BrowseRow>();
    private BrowseAdapter adapter;
    private ListView list;
    private TextView browseTitle;
    private TextView changeLink;
    private SearchCriteria sc =SearchCriteria.getInstance();

    private JSONArray jsonArray;
    private ProgressDialog m_ProgressDialog = null; 
    private Runnable progressRunnable;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        try {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.browse);
            String errorMsg =Util.getExtraValue(getIntent().getExtras(), WLConstants.ERROR_MSG); 
            list =(ListView)findViewById(R.id.browse_cats);
            if(errorMsg!= null){
                UIFactory.displayAlert(new AlertDialog.Builder(HomeBrowse.this), "Status", errorMsg);
            }
            progressRunnable = new Runnable(){
                @Override
                public void run() {
                 try {

                    loadData();
                    } catch (Throwable e) {
                        Log.e(TAG, e.getMessage());
                        }
                     runOnUiThread(returnRes);
                }
            };
            m_ProgressDialog = ProgressDialog.show(HomeBrowse.this,    
                      "Please wait...", "Loading ...", true);
            Thread thread = new Thread(progressRunnable);
            thread.start();
        } catch (Throwable e) {
            Log.e(TAG, e.getMessage());
            Util.handleError(HomeBrowse.this, HomeBrowse.class, e.getMessage());
            //UIFactory.displayAlert(new AlertDialog.Builder(HomeBrowse.this), "Error Loading categories", e.getMessage());
        }
    }

    private void loadData()throws Throwable{//loading object

        jsonArray = JSONService.getJsonArray(getResources().getString(R.string.catJson));

    }
    private void fillResultRows(JSONArray jsonArray, BrowseAdapter adapter)throws Throwable{
        BrowseRow br = null;
        try {
            for(int a=0; a<jsonArray.length(); a++){
                JSONObject jsonObj = jsonArray.getJSONObject(a);
                br = new BrowseRow();
                br.name=jsonObj.getString("title");
                br.image=jsonObj.getString("image");
                br.searchType = jsonObj.getInt("searchType");

                if(jsonObj.has("categoryIds")){
                    br.categoryIds = jsonObj.getString("categoryIds").replaceAll("-", ",");
                }
                if(jsonObj.has("subCategoryIds")){
                    br.subCategoryIds = jsonObj.getString("subCategoryIds").replaceAll("-", ",");
                }
                adapter.add(br);
            }
        } catch (Throwable e) {
            throw e;
        }

        }

    class BrowseAdapter extends ArrayAdapter<BrowseRow> {
        BrowseAdapter() {
            super(HomeBrowse.this, android.R.layout.simple_list_item_1, model);
        }

        public View getView(int position, View convertView,
                                                ViewGroup parent) {
            View row=convertView;
            ResultWrapper wrapper=null;

            if (row==null) {                                                    
                LayoutInflater inflater=getLayoutInflater();

                row=inflater.inflate(R.layout.browse_row, null);
                wrapper=new ResultWrapper(row);
                row.setTag(wrapper);
            }
            else {
                wrapper=(ResultWrapper)row.getTag();
            }

            wrapper.populateFrom(model.get(position));
            return(row);
        }
    }
    class ResultWrapper {
        private TextView name;
        private String catIds="0";
        private String subCatIds="0";
        private ImageView image;
        private int searchType;

        private View row=null;

        ResultWrapper(View row) {
            this.row=row;
        }

        void populateFrom(BrowseRow r) {
            getName().setText(r.name);
            getIcon().setImageResource(getImageIcon(Integer.parseInt(r.image)));
            catIds =r.categoryIds;
            subCatIds = r.subCategoryIds;
            searchType =r.searchType;
        }
        TextView getName() {
            if (name==null) {
                name=(TextView)row.findViewById(R.id.browse_row_name);
            }
            return name;
        }
        ImageView getIcon() {
            if (image==null) {
                image=(ImageView)row.findViewById(R.id.browse_row_icon);
            }
            return image;
        }


    }

    private int getImageIcon(int catId){

        int imageSource=R.drawable.all_cats;

        switch(catId){
        case WLConstants.CATEGORY_FILM: imageSource =R.drawable.film; break;  
        case WLConstants.CATEGORY_MUSIC: imageSource =R.drawable.music; break;
        case WLConstants.CATEGORY_ARTS: imageSource =R.drawable.art; break;
        case WLConstants.CATEGORY_KIDS: imageSource =R.drawable.museum; break;
        case WLConstants.CATEGORY_GALLERY_MUSEUM: imageSource =R.drawable.kids; break;
        case WLConstants.CATEGORY_COMEDY: imageSource =R.drawable.comedy; break;
        case WLConstants.CATEGORY_NIGHT_CLUBS: imageSource =R.drawable.clubs; break;
        case WLConstants.CATEGORY_ATTRACTION: imageSource =R.drawable.touristattractions; break;
        case WLConstants.CATEGORY_VARIOUS_EVENTS: imageSource =R.drawable.all_cats; break;
        case WLConstants.CATEGORY_ALL_FOOD_DRINK: imageSource =R.drawable.restaurants; break;
        }
        return imageSource;
    }
    @Override
    public void onItemClick(AdapterView<?> adp, View view, int item, long arg3) {

        try {
            if("".equals(sc.getSearchLocation()) && (!(Util.locationFound(sc.getGeoLocation()) && sc.isUK()))){
                UIFactory.displayAlert(new AlertDialog.Builder(HomeBrowse.this), "Error", "Please provide location");
                return;
            }
                ResultWrapper wrap = (ResultWrapper)view.getTag();
                sc.setCategoryIds(wrap.catIds);
                sc.setSubCategoryIds(wrap.subCatIds);
                sc.setSearchType(wrap.searchType);
                goSearch();
        } catch (Throwable e) {
            Log.e(TAG, e.getMessage());
            Util.handleError(HomeBrowse.this, HomeBrowse.class, e.getMessage());
            //UIFactory.displayAlert(new AlertDialog.Builder(this), "Error", e.getMessage());
        }
    }
    private void applyListener(){
        list.setOnItemClickListener(this);
        changeLink.setOnClickListener(onclickListener);

    }
    private final void goSearch(){
          try {
              sc.setSearchString("");
              Intent mainIntent = new Intent(HomeBrowse.this,SearchResults.class); 
              startActivity(mainIntent); 
        } catch (Throwable e) {
            Log.e(TAG, e.getMessage());
            Util.handleError(HomeBrowse.this, HomeBrowse.class, e.getMessage());
        }

      }
    public OnClickListener onclickListener = new OnClickListener(){ 
        // @Override 
        public void onClick(View aView) {
             try {
                int componentId =aView.getId();
                 switch(componentId){
                 case R.id.tv_changeDateType: 
                     Intent intent = new Intent(HomeBrowse.this,TimeLocationSettings.class);
                     startActivity(intent);
                     break;
                 }
            } catch (Exception e) {
                Log.e(TAG, e.getMessage());
                Util.handleError(HomeBrowse.this, HomeBrowse.class, e.getMessage());
            }
        }

  }; 

  private void configComponents(){
      String titleStr,location = "";
      String dateCrtStr = Util.getDateCritieraStr(sc.getDateCriteria());
      titleStr= dateCrtStr;
      if(!"".equals(sc.getSearchLocation())){
          location = sc.getSearchLocation();
      }else if(sc.isNearMe()){
          location="Near me";
      }else{
          location = "Postcode or town";
      }
      titleStr = titleStr + " - "+ location;
      browseTitle.setText(titleStr);
      changeLink.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
      }


  public class BrowseRow {

        private String name = "";
        private String image = "";
        private String categoryIds="0";
        private String subCategoryIds="0";
        private int searchType=1;

    }
  private Runnable returnRes = new Runnable() {
        @Override
        public void run() {
            try {
                browseTitle = (TextView)findViewById(R.id.browsePageTite);
                changeLink = (TextView)findViewById(R.id.tv_changeDateType);
                changeLink.setText(Html.fromHtml("<a href='#'>Change</a>"));
                adapter=new BrowseAdapter();
                applyListener();
                configComponents();
                fillResultRows(jsonArray, adapter);
                if(jsonArray == null){
                    UIFactory.displayAlert(new AlertDialog.Builder(HomeBrowse.this), "Error", "Error Loading categories");
                    return;
                }
                list.setAdapter(adapter);
            } catch (Throwable e) {
                e.printStackTrace();
            } 
            m_ProgressDialog.dismiss();
        }
      };
}
  • 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-05-13T09:43:59+00:00Added an answer on May 13, 2026 at 9:43 am

    You should be saving everything that describes the view’s state that isn’t saved elsewhere.

    Save where the user is in a EditText, what value the EditText has, what dialog is currently displayed, etc. Your application should be able to reconstruct the exact state it was in from the bundle returned to in when it is paused by the user leaving the application and returning to it.

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

Sidebar

Related Questions

I'm having trouble following this guide to extract my interfaces and entities from my
Please consider this example class: [Serializable] public class SomeClass { private DateTime _SomeDateTime; public
Please provide tips for effectively using git with svn. What are your best practices?
i am using following code to setlistview adapter but giving me error at last
Please suggest some good resources to start writing Java Web services.
Please read the whole question. I'm not looking for an approach to managing multi-lingual
Please give me the direction of the best guidance on the Entity Framework.
Please bear with me, I'm just learning C++. I'm trying to write my header
Please explain to me why the very last echo statement is blank? I expect
Please excuse the vague title. If anyone has a suggestion, please let me know!

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.