As I understand it you only want the intent-filter in the activity
that does the searching.  The intent filter says the to platform "hey
I can do this"
Then in the activities you want to use the search you can
startActivityForResult()


On Dec 15, 12:11 pm, Stefan Klumpp <[email protected]> wrote:
>  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) it always pauses ACTIVITY_2 first
> and then goes to onCreate() of ACTIVITY_2.
>
> @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);
>     }
>
> }
>
>     * 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>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to