Intent Web Search with keyword

Description

The following code shows how to do Intent Web Search with keyword.

Example

Main Activity Java code


/*  w  w w .ja va  2s  .c o  m*/
import java.io.File;
import java.util.ArrayList;

import android.app.Activity;
import android.app.SearchManager;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.Contacts;
import android.view.Menu;

public class MainActivity extends Activity {

    private Intent browserIntent;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        browserIntent = new Intent();
        //browserIntent.setAction(Intent.ACTION_VIEW);
        //browserIntent.setData(Uri.parse("http://www.google.com"));
        browserIntent.setAction(Intent.ACTION_WEB_SEARCH);
        browserIntent.putExtra(SearchManager.QUERY, "puppies");
        
        
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        menu.add("Browser").setIntent(browserIntent);
        return true;
    }

}
Intent Web Search with keyword




















Home »
  Android »
    Android Basics »




Hello Android
Resources
Activity
Calendar
Camera
Contact
Content Provider
Database
Hardware
Intent
Location
Media
Network
Notification
Preference
Sensor
Service
SMS