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
www.google.com. However, I am getting an error:

url =  http://www.google.com/search?& ;q=123

java.io.FileNotFoundException:  http://www.google.com/search?& ;q=123
   at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1040)
   at com.nubinews.reader.URLFetcher.readHttp(URLFetcher.java:535)
   at
com.nubinews.reader.URLFetcher$ConnectionThread.getText2Internal(URLFetcher.java:417)
   at
com.nubinews.reader.URLFetcher$ConnectionThread.getText2InThread(URLFetcher.java:365)
   at
com.nubinews.reader.URLFetcher$ConnectionThread.processCommands(URLFetcher.java:341)
   at
com.nubinews.reader.URLFetcher$ConnectionThread.run(URLFetcher.java:323)

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 www.google.com:80 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();
        System.out.println(map);

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 <mattaku.betsu...@gmail.com




--~--~---------~--~----~------------~-------~--~----~



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:

 http://www.google.com/codesearch/p?hl=en #uX1GffpyOZk/core/java/android/net/http/AndroidHttpClient.java&q=AndroidHttpClient.java

On Fri, Mar 6, 2009 at 9:31 AM, Mattaku Betsujin <mattaku.betsu...@gmail.com





--~--~---------~--~----~------------~-------~--~----~



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?

 http://www.google.com/accounts/TOS 

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

 http://code.google.com/apis/ajaxsearch/ 

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
_The Busy Coder's Guide to Android Development_ Version 2.0 Available!

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Make My App Available By Intent

Maybe this belongs in the beginners group, but I'm trying to make my
application available through an intent. It's a volume controller app,
so I figured it might be handy for another application to be able to
call it to adjust volume without having to write their own.

In my volume controller app, I have this activity as my main screen:

<activity android:name=".MainSettings" android:label="@string/
app_name">
                        <intent-filter>
                                <action 
android:name="android.intent.action.MAIN" />
                                <category 
android:name="android.intent.category.LAUNCHER" />
                        </intent-filter>
            <intent-filter>
                <action android:name="intent.action.VOLUME_CONTROL"/>
                                <category 
android:name="android.intent.category.DEFAULT" />
            </intent-filter>
</activity>


Intent intent = new Intent();
intent.setAction("intent.action.VOLUME_CONTROL");
startActivity(intent);

Or I've tried:

Intent intent = new Intent("com.roozen.intent.action.VOLUME_CONTROL");
startActivity(intent);

Neither works. The process trying to call the other app fails. I've
also tried removing the category.DEFAULT category from my intent
filter, with no success.

What am I missing?
--~--~---------~--~----~------------~-------~--~----~

2. Creating YAFFS2 Image

Hi all,

I'm able to generate CRAMFS and JFFS2 but unable to find a way to
generate/convert YAFFS2 Image out of the android file system, could
anyone give me some hints?

Thank you.
--~--~---------~--~----~------------~-------~--~----~
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

3. PAGE_OFFSET definition for MSM7201A chipset

4. How to launch a viewer for common file types?

5. How to launch a viewer for common file types?

6. Nightly Build for Emulator

7. Extending keyevent keycodes