I am not using a SearchManager, but I have built my own custom search activity. I want this to be shown when the user clicks on the Search button. How can I do this?
If I understand you correctly, you are asking how to launch your search activity. Create an onClickListener for your button and an EditText field for the user to input text. Query the intent in your search activity to get whatever the user was searching for when the user clicks on the "search" button.
EditText et = new EditText(this);
public void onClick(View v){
String searchText = et.getText();
Intent intent = new Intent(this, com.example.app.SearchActivity.class);
intent.putExtra("searchQuery", searchText);
startActivity(intent);
}
http://developer.android.com/guide/appendix/faq/commontasks.html#opennewscreen
Inside of your own application, you can do this via monitoring onKeyDown()
, AFAIK.
Inside other applications, this is not possible except via custom firmware.
Not sure if this will work or not, but have you tried extending a BroadcastReceiver that can catch the search's intent? Checking the developer reference the intent seems to be "android.search.action.GLOBAL_SEARCH". So, you'll have a Receiver class like:
public class MyIntentReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("android.search.action.GLOBAL_SEARCH")) {
Intent sendIntent = new Intent(context, MySearchActivity.class)
context.startActivity(intent);
}
}
}
In your manifest, between the application tags, you should have
<receiver android:name="MyIntentReceiver">
<intent-filter>
<action android:name="android.search.action.GLOBAL_SEARCH" />
</intent-filter>
</receiver>