Hello i am using android 3.0 search widget(not the search mode), the problem is i need to pass some parameters along with the search word.
Android isn't calling any of these
searchManager.setOnDismissListener( new OnDismissListener() {
@Override
public void onDismiss() {
// TODO Auto-generated method stub
Log.v(MyApp.TAG, "on dismiss search");
}
});
searchManager.setOnCancelListener( new OnCancelListener() {
@Override
public void onCancel() {
// TODO Auto-generated method stub
Log.v(MyApp.TAG, "on dismiss cancel");
}
});
@Override
public boolean onSearchRequested() {
Bundle appData = new Bundle();
appData.putLong("listino_id", this.listino_id);
this.startSearch(null, true, appData, false);
return true;
// return super.onSearchRequested();
}
I need my activity to NOT be singleOnTop, here is my AndroidManifest.xml
<activity android:name=".activity.ListinoProdottiActivity" android:windowSoftInputMode="stateHidden">
<!-- Receives the search request. -->
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<!-- No category needed, because the Intent will specify this class component-->
</intent-filter>
<!-- enable the base activity to send searches to itself -->
<meta-data android:name="android.app.default_searchable"
android:value=".activity.ListinoProdottiActivity" />
<!-- Points to searchable meta data. -->
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>
Here is my searchable.xml
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/app_name"
/>
Check if you have hard coded strings for
android:hint
orandroid:label
in res/xml/searchable.xml. They must be string resource ids.pass data with bundle in Search Widget:
layout/main.xml :
layout/searchable.xml :
values/strings.xml :
AndroidManifest.xml :
ResultActivty.java:
SearchWidgetExampleTest.java :
Happly Coding!!!
you can use the follow
in Menu
and in your search result activity put the below
when querying by searchview ( searchable || searchview widget ) you can pass parameter to searchActivity ( searchResultActivity ) by define your own OnQueryTextListener like this.
If your calls is syncronic(you perform one search request and waiting for response and don't perform any search request until you got your response) then it's easy.
Just create a helper static class to do it for you.
Some thing like this: