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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T02:08:44+00:00 2026-05-13T02:08:44+00:00

I have an activity handling search ( ACTIVITY_1 ), which works perfectly when I

  • 0

I have an activity handling search (ACTIVITY_1), which works perfectly when I use the search (via SEARCH button on the phone) within/from this activity.

However, when I use search from another activity (ACTIVITY_2..x) by implementing onNewIntent and forward the query string to my Search_Activity.class (ACTIVITY_1)

@Override
protected void onNewIntent(Intent intent) {
    Log.i(TAG, "onNewIntent()");

    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        Log.i(TAG, "===== Intent: ACTION_SEARCH =====");
        Intent myIntent = new Intent(getBaseContext(), Search_Activity.class);
        myIntent.setAction(Intent.ACTION_SEARCH);
        myIntent.putExtra(SearchManager.QUERY, intent.getStringExtra(SearchManager.QUERY));
        startActivity(myIntent);
    }

}

it always pauses ACTIVITY_2 first and then goes to onCreate() of ACTIVITY_2.

  • Why does it recreate my ACTIVITY_2 when it is already there and doesn’t go to onNewIntent directly?
  • Is there another way I can forward search queries directly to ACTIVITY_1? For example via a setting in the Manifest.xml
  • Is it possible to generally forward all search queries automatically to ACTIVITY_1 without even implementing onNewIntent in all the other activities?

Currently I have to put an <intent-filter> in every single activity to “activate” my custom search there and forward the query then to the activity that handles search via the onNewIntent (as shown above).

<activity android:name=".Another_Activity"
    android:theme="@style/MyTheme">
    <intent-filter>
        <action android:name="android.intent.action.SEARCH" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
    <meta-data android:name="android.app.searchable"
        android:resource="@xml/searchable" />
</activity>
  • 1 1 Answer
  • 1 View
  • 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-13T02:08:45+00:00Added an answer on May 13, 2026 at 2:08 am

    I’m not sure I understand the chain of events your describing, but here’s how you need to configure your application in the case were ACTIVITY_1 is the search Activity you always want to launch from all your other Activities when the user presses the ‘search’ button.

    Assuming that the search button works perfectly on Activity1, you just need to add a bit of glue meta-data to your application telling it that all your other Activities should use ACTIVITY_1 for searching, as shown in the manifest snippet below:

    <application>
      <meta-data 
         android:name="android.app.default_searchable"
         android:value=".ACTIVITY_1" />
    
       <!-- All your activities, service, etc. -->
    
    </application>
    

    Using this, you should be able to remove the intent-filters from all but ACTIVITY_1, and you won’t need to use the onNewIntent handler in any of your other Activities.

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

Sidebar

Related Questions

I have an activity which have a button and a listview(with chechbox, image and
I am having trouble with my activity management. So I have activity A which
I have an activity with the following layout. So in this screen, initally the
I have an activity with a spinner which loads a simpleCursorAdaptor. I call another
I have a form which renders, but when I click the submit button, I
I have listView in which I inflate a row contain textview and button now
i have two sub activities apart from main activity. The sequence of calls go
I have a link from that link: http://api.maxxiscentral.com/maxxiscentral/GetTyrePatterns from this link i want to
I currently have a Google Map Activity which is apparently working well but doesn't
I have a rather large app which works in the simulator but creates in

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.