How to do a google search?

by Mattaku Betsujin » Fri, 06 Mar 2009 16:06:17 GMT

Sponsored Links
 I want to do a google search, so I open an HttpURLConnection() to However, I am getting an error:

url = ;q=123 ;q=123
   at com.nubinews.reader.URLFetcher.readHttp(

and the response headers are:

HEADER: null = HTTP/1.1 403 Forbidden
HEADER: content-type = text/html; charset=UTF-8
HEADER: date = Fri, 06 Mar 2009 08:02:53 GMT
HEADER: server = gws
HEADER: cache-control = private, x-gzip-ok=""
HEADER: transfer-encoding = chunked

What should I do?


How to do a google search?

by Mattaku Betsujin » Fri, 06 Mar 2009 16:31:34 GMT

 I found a work-around. Instead of using HttpURLConnection, I open a socket
connection directly to and was able to get the search
results (in HTML data). It seems like Android's HttpURLConnection adds
request header to make my life miserable.

However, when I tried to print the request headers

        Map map = http.getRequestProperties();

It shows an empty collection.

What's happening? Does Google really doesn't want me to search? Please, I
beg you, let me search ........

On Fri, Mar 6, 2009 at 12:06 AM, Mattaku Betsujin <


Sponsored Links

How to do a google search?

by Mariano Kamp » Fri, 06 Mar 2009 19:09:42 GMT

 Just out of curiosity, have you tried the url without the "&"?. Afaik the
first parameter is passed in with a "?" and just the following parameters
are prefixed with the "?". But you did both for the first parameter.

On Fri, Mar 6, 2009 at 9:06 AM, Mattaku Betsujin <


How to do a google search?

by Mariano Kamp » Fri, 06 Mar 2009 19:14:47 GMT

 > It seems like Android's HttpURLConnection adds request header [to make my
life miserable.]
How do you know?

The HTTPUrlConnection works fine for me. The documentation is a bit lacking,
but since I found the following code I am happy: #uX1GffpyOZk/core/java/android/net/http/

On Fri, Mar 6, 2009 at 9:31 AM, Mattaku Betsujin <


How to do a google search?

by Mark Murphy » Fri, 06 Mar 2009 19:59:03 GMT


You do realize that what you are trying to do violates Google's Terms of
Service, right? 

If you want to use Google's search, use their official APIs for search: 

Mark Murphy (a Commons Guy) 
_The Busy Coder's Guide to Android Development_ Version 2.0 Available!


Other Threads

1. How to launch the street view from map view

New to android, please forgive if this question sounds naive.

The latest MapView can check whether the map is in street view mode
and allow users to toggle it.

However, the set street view api only display the blue layout on top
of the map. Is there any way that I can launch the street view like in
Google Map.

Also, does this version support route and direction?

Please kindly advice. Thanks


2. listActivity and checkBox


Android supports to bind and populate data to a list view in
listActivity through some adapters.

You can define the list view in a xml file. Take notePad as example:

// noteslist_item.xml
<TextView xmlns:android=""

Then you can bind the data in the java code by an adapter: for example


        Cursor cursor = managedQuery(getIntent().getData(),
PROJECTION, null, null,

        // Used to map notes entries from the database to views
        SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
R.layout.noteslist_item, cursor,
                new String[] { Notes.TITLE }, new int[]
{ });

It works fine. Now my question is how to differentiate those populated
TextView? Do they have different IDs?

If the list item is a complex view with checkBox or radio button, how
can we check their status/state respectively?




3. About the use of the Wi-Fi function

4. Images and Layout Questions

5. how to get access to private API s

6. EventHandler ?

7. *** TCP connect() time out ***