android - Is there any good solution for searching in TabActivity for each activity in tab respectively? -


i have problem activities navigation, searching works good.

activities hierarchy looks that:

                              /  mylistactivitya -- itemactivitya mainactivity -- mytabactivity -- mylistactivityb -- itemactivityb                               \  mylistactivityb -- itemactivityc 

tabs in tabactivity created using intents mylistactivity.

mylistactivities declared in manifest below:

    <activity         android:name=".views.orderlistview">         <intent-filter>             <action                 android:name="android.intent.action.search" />         </intent-filter>         <meta-data             android:name="android.app.searchable"             android:resource="@xml/searchable_orders" />     </activity> 

every mylistactivity has own searchrecentsuggestionsprovider.

first resolved problem

when invoked search on of mylistactivity got activity outside mytabactivity. therefore implemented redirecting mytabactivity.
in oncreate() of mylistactivity intent action checked. if it's

intent.action_search 

then start tabactivity , finish current, below:

    if(intent.action_search.equals(intent.getaction())) {         string query = intent.getstringextra(searchmanager.query);         intent.setclass(context, mytabactivity.class);         intent.setaction(mytabactivity.action_search_proxy);          bundle appdata = intent.getbundleextra(searchmanager.app_data);          if(appdata != null) {             intent.putextras(appdata);         }          intent.putextra(constants.activity_type, activitytype);         intent.putextra(activitytabview.extra_search_query, query);          context.startactivity(intent);         context.finish();     } 

when mylistactivity find

activitytabview.extra_search_query 

it makes search query on list. , problem resolved.

second resolved problem

clicking "back" button clears search query - that's ok. clicking "back" again shows past searches.

that's why put nohistory mytabactivity:

<activity     android:name=".views.mytabactivity"     android:nohistory="true"> </activity> 

third unresolved problem

now, example, going mylistactivitya itemactivitya , clicking "back" redirects mainactivity. can't mytabactivity because of nohistory parameter.

is there solution using android searching in tabactivity each activity in tab respectively?

i recommend read tasks , stack. gave me better understandings of activities stack in android.

my solution:

invoked quick search dialog starts activity invoked, in example mylistactivity. makes tabactivity dissapear, that's why there no visible tabwidget. therefore in mylistactivity implemented redirection mytabactivity (see first resolved problem). mytabactivity redirects extras, search query, included in intent specific mylistactivity.

all have add 1 line. set flag_activity_clear_top flag on intent starts mytabactivity.

if(intent.action_search.equals(intent.getaction())) {     string query = intent.getstringextra(searchmanager.query);     intent.setclass(context, mytabactivity.class);     intent.setaction(mytabactivity.action_search_proxy);      bundle appdata = intent.getbundleextra(searchmanager.app_data);      if(appdata != null) {         intent.putextras(appdata);     }      intent.putextra(constants.activity_type, activitytype);     intent.putextra(activitytabview.extra_search_query, query);      //added line     intent.setflags(intent.flag_activity_clear_top);      context.startactivity(intent);     context.finish(); } 

then normal activities navigation preserved.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -