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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:40:40+00:00 2026-06-03T13:40:40+00:00

Does somebody know of a tutorial or an example of how to implement the

  • 0

Does somebody know of a tutorial or an example of how to implement the standard Android search interface with Fragments? In other words, is it possible to put a standard search with a SearchManager in a Fragment?

  • 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-03T13:40:43+00:00Added an answer on June 3, 2026 at 1:40 pm

    In short, you can’t. There are a couple of reasons why creating a search interface within a Fragment is not possible.

    1. When creating a searchable interface, you must specify a default “searchable activity” in your Android manifest. As I’m sure you know, a Fragment cannot exist without a parent Activity and thus, this separation is not possible.

    2. If you already figured out #1 already, I assume you asked this question in hopes that there is some magical “hack” out there that can get the job done. However, the documentation states that,

      When the user executes a search in the search dialog or widget, the
      system starts your searchable activity and delivers it the search
      query in an Intent with the ACTION_SEARCH action. Your searchable
      activity retrieves the query from the intent’s QUERY extra, then
      searches your data and presents the results.

      The underlying, internal system that is responsible for providing search results expects an Activity, not a Fragment; thus, implementing a search interface that is completely independent of an Activity is not possible, as it would require changes to the underlying system itself. Check out the source code for the SearchableInfo class if you don’t believe me :).

    That being said, it doesn’t seem like it would be too difficult to achieve something similar to what you are describing. For instance, you might consider implementing your searchable-Activity so that it will accept the android.intent.action.SEARCH intent and (instead of immediately displaying the results in a ListView, for example) will pass the search query to your Fragments. For instance, consider the following searchable Activity:

    public class SearchableActivity extends Activity {
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) {
              String query = intent.getStringExtra(SearchManager.QUERY);
              doMySearch(query);
            }
        }
    
        /**
         * Performs a search and passes the results to the container
         * Activity that holds your Fragments.
         */
        public void doMySearch(String query) {
            // TODO: implement this
        }
    }
    

    When a search-request is made, the system will launch your searchable activity, perform the query, and will pass the results to some container Activity (based on your implementation of doMySearch). The container Activity will then pass these results to the contained searchable Fragment, in which the results will be displayed. The implementation requires a bit more work than what you were probably hoping for, but I’m sure there are ways that you can make it more modular, and it seems like this might be the best that you can do.

    p.s. If you use this approach, you might have to pay special attention to which Activitys are added/removed to the backstack. See this post for some more information on how this might be done.

    p.p.s. You might also forget about the standard search interface completely and just implement a simple search within a Fragment as described in Raghav’s post below.

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

Sidebar

Related Questions

Does somebody know a module, which has a function that returns ( for example
Does somebody know, how to call a lightbox from an custom link? Example: $('#price1
Does somebody know a Javascript menu (in Jquery if possible) similar to the javascript
Does somebody know how to use FFMPEG on Android to convert YUV420 frame to
Does somebody know if is it possible somehow to create a custom NSAnimationCurve so
Does somebody know if it is possible to specify the data source of a
Does somebody know if it is possible to change one of documents in a
Does somebody know how to unload a dll or any other type of module
Does somebody know a script that is able to convert a string to a
Does somebody know a quick and easy explode() like function that can ignore splitter

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.