0

I am making an android application that needs to open the webbrowser when the go button on quick search is pressed. How can i make this happen? that it starts the webbrowser? This is the code that i got so far:

public class SearchFunction extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    final Intent queryIntent = getIntent();
    final String queryAction = queryIntent.getAction();
    if (Intent.ACTION_SEARCH.equals(queryAction)) {
        String searchKeywords = queryIntent.getStringExtra(SearchManager.QUERY);
        //Is it here that i can start intents/webbrowser???
    }
}
}
animuson
  • 53,861
  • 28
  • 137
  • 147
user1183066
  • 115
  • 2
  • 6
  • 20

1 Answers1

0

For how to do the search activity you have all the info here: http://developer.android.com/guide/topics/search/search-dialog.html

Starting the browser:

Intent i = new Intent(Intent.ACTION_VIEW, 
       Uri.parse("http://www.google.ro/search?q=" + searchKeywords.replace(' ', '+')));
startActivity(i);

Hope it helps.

Andrei
  • 168
  • 1
  • 8
  • I tried it, but it doesn't happen anything once i press the search button, how can i fix this is my question. I'll try to go through some manuals and such again – user1183066 Feb 09 '12 at 15:11