I have problem with Activities navigation, searching works good.
Activities hierarchy looks like that:
/ MyListActivityA -- ItemActivityA
MainActivity -- MyTabActivity -- MyListActivityB -- ItemActivityB
\ MyListActivityB -- ItemActivityC
Tabs in TabActivity are created using Intents with MyListActivity.
MyListActivities are declared in manifest like 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 any of MyListActivity I got the activity outside the MyTabActivity. Therefore implemented redirecting to MyTabActivity.
In onCreate() of MyListActivity intent action is checked. If it's
Intent.ACTION_SEARCH
then start TabActivity and finish current, like 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. And problem resolved.
Second resolved problem
Clicking "Back" button clears search query - that's ok. But clicking "Back" again shows past searches.
That's why I put noHistory to MyTabActivity:
<activity
android:name=".views.MyTabActivity"
android:noHistory="true">
</activity>
Third UNresolved problem
Now, for example, going from MyListActivityA to ItemActivityA and clicking "Back" redirects to MainActivity. I can't do back to MyTabActivity because of noHistory parameter.
Is there any good solution for using Android searching in TabActivity for each activity in tab respectively?