First, be sure you are not violating the google terms of use. Second, set the User-Agent request property for the URLConnection. I cannot recall the exact code, but something like:

...