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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:18:36+00:00 2026-05-26T23:18:36+00:00

I want to implement a search in my Android application. In this page, first

  • 0

I want to implement a search in my Android application.
In this page, first I am displaying a user list and then performing a search on the user list. Both are in the same activity. In the following manner, I am getting intent and some values from the previous page. When I display the user list, all the values are coming. But while performing search, spaceId gets lost and becomes null. I need this value.

Intent intent = this.getIntent();
Bundle receiveBundle = intent.getExtras();
spaceId = receiveBundle.getString("spaceId");

What should I do to get this value?

Edit:

String spaceId;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    Intent intent = this.getIntent();
        Bundle receiveBundle = intent.getExtras();
        spaceId = receiveBundle.getString("spaceId");
        String URLTicketList = String.format(getString(R.string.URLTicketList, spaceId));
        RestClient client = new RestClient(URLTicketList,
                this.getApplicationContext());
        try {
            client.Execute(RequestMethod.GET);
        } catch (Exception e) {
            e.printStackTrace();
        }

        TabSettings ts = new TabSettings();
        ts.setSelTab(0);
        String response  = client.getResponse();
        tickets = parseTicketList(response);
        if (Intent.ACTION_SEARCH.equals(intent.getAction())) {

            String query = intent.getStringExtra(SearchManager.QUERY);
            searchResult=getMatchingStrings(tickets,query);
            this.ticket_adapter = new TicketAdapter(this,
                        R.layout.ticket_details_row,searchResult);
            setListAdapter(this.ticket_adapter);
        }
        else  {
            this.ticket_adapter = new TicketAdapter(this,
                        R.layout.ticket_details_row, tickets);
            setListAdapter(this.ticket_adapter);
        }

    }

getMatchingstrings()

ArrayList<Ticket> getMatchingStrings(ArrayList<Ticket> list, String regex1)     {
        ArrayList <Ticket> listClone = new ArrayList<Ticket>(); 
            for (Ticket string : list) {
                    if(string.getAssignedTo().equals(regex1)){
                listClone.add(string);
                }
            }

          return listClone;
        }
  • 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-26T23:18:36+00:00Added an answer on May 26, 2026 at 11:18 pm

    You said your activity is recreating. So you are not getting the value of spaceID after recreation. Then do this thing as below.

    public String PREFS_NAME = "Shared_Pref";
    
    Bundle receiveBundle = this.getIntent().getExtras();
    String spaceId_value = receiveBundle.getString("spaceId");
    
    SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
    
    if(spaceId_value == null) {
         spaceId_value = settings.getString("spaceId", "");
    }
    else {
         SharedPreferences.Editor editor = settings.edit();
         editor.putString("spaceId", spaceId_value);
    }
    

    I hope this will help you out.

    edit :

    I am editing your code.

    Which part i have edited, i have mentioned that part as edited. Carefully see what i have changed and do that thing in your code. Then let me know.

         String spaceId;
         public String PREFS_NAME = "Shared_Pref";  //edited part
    
         public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
    
            //editing start
    
             SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
             Bundle receiveBundle = this.getIntent().getExtras();
             if(receiveBundle != null) {
                 spaceId = receiveBundle.getString("spaceId");
                 if(spaceId == null) {
                     spaceId = settings.getString("spaceId", "");
                 }
                 else {
                     SharedPreferences.Editor editor = settings.edit();
                     editor.putString("spaceId", spaceId);
                 }
             }
    
            //editing end
    
            String URLTicketList = String.format(getString(R.string.URLTicketList, spaceId));
            RestClient client = new RestClient(URLTicketList,
                this.getApplicationContext());
            try {
                client.Execute(RequestMethod.GET);
            } catch (Exception e) {
                e.printStackTrace();
            }
    
            TabSettings ts = new TabSettings();
            ts.setSelTab(0);
            String response  = client.getResponse();
            tickets = parseTicketList(response);
            if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
    
                String query = intent.getStringExtra(SearchManager.QUERY);
                searchResult=getMatchingStrings(tickets,query);
                this.ticket_adapter = new TicketAdapter(this,
                            R.layout.ticket_details_row,searchResult);
                setListAdapter(this.ticket_adapter);
            }
            else  {
                this.ticket_adapter = new TicketAdapter(this,
                            R.layout.ticket_details_row, tickets);
                setListAdapter(this.ticket_adapter);
            }
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to implement search bar in my application which will filter list view
I want to implement search feature in my application. I read about android searchable
i want to implement a small search engine , i have index page where
I want to implement the user authentication and login page in ASP.NET, I want
I want to implement a search feature in an iPhone app. Basically, the user
I want to implement the search option for my application,and auto fill option for
I want to implement full text search and what I do is this: NSString*
I'm trying to implement Search Engine. I have web application that displays list of
I am working on C#.Net windows application. Here i want to implement search functionality
I want to implement search functionality for a website (assume it is similar to

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.