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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:33:46+00:00 2026-06-18T04:33:46+00:00

I am successfully using a search widget in my action bar to perform a

  • 0

I am successfully using a search widget in my action bar to perform a search following this guide. The search is fine, but I’m wondering how to pass additional variables on a search. The same guide states I can override onSearchRequested(), but this doesn’t seem to work with a search widget.

  • Override in question:

    @Override
    public boolean onSearchRequested() {    
        Bundle appData = new Bundle();
        appData.putString("KEY", "VALUE");
        startSearch(null, false, appData, false);
        return true;
    }
    
  • Getting the bundle in my activity class:

    protected void onCreate(Bundle savedInstanceState) {
        // ...
        Intent intent = getIntent();
        Bundle appData = intent.getBundleExtra(SearchManager.APP_DATA);
        String value = appData.getString("KEY");
        Log.d("VALUE", value);
        // ...
    }
    

My application crashes upon creating the search class because appData is always null.

Note

onSearchRequested() is called, but the bundle does not make it to my onCreate() method.

All extras from the passed intent are {user_query=my-query, query=my-query}.

  • 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-18T04:33:47+00:00Added an answer on June 18, 2026 at 4:33 am

    It seems the only way to do this is to intercept new activities created in your activity which is search-enabled. To do this we override the startActivity() method. We can then check to make sure the activity is indeed the search activity, then add an extra to the intent. The working code is below.

    @Override
    public void startActivity(Intent intent) {      
        // check if search intent
        if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
            intent.putExtra("KEY", "VALUE");
        }
    
        super.startActivity(intent);
    }
    

    You can then grab your extra as you would any other extra in your search activity using:

    mValue = intent.getStringExtra("KEY");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been successfully using Django's admin panel for internal users for a while but
I have successfully indexed files, and want to be able to search using wildcards.
Using the django-haystack and solr as a search engine, I have successfully implemented a
I want to search content from a site using WWW::Mechanize but to be able
I've successfully gotten my menu to be sticky using jQuery waypoints in this jsFiddle
I can get data from MySql with use of php using android successfully. But
I am using mechanize to perform a bing search and then I will process
We have been using Microsofts LiveSearchService successfully for a number of years but just
I build my project(include subproject Three20) successfully using xcode GUI,but when I use xcodebuild,it
Using Perl find I cannot successfully escape a DOCTYPE declaration in search string. Here

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.