I'm trying to open a webpage in my app using :

try {
URL url = new URL(rl);

    // Get the response
    BufferedReader rd = new BufferedReader(
    new InputStreamReader(url.openStream()));
}
catch (Exception e) {}


It works great, and when there is no internet connection, it  catches
the error fast in one second. However, if the phone is connected to
WiFi, and the WiFi has no internet Access. It takes forever and the
main thread will finally crash. I tried using a new thread other than
the main thread for the app, it worked but still it takes about 30
seconds to catch that there is no internet connection.

I need it to catch the error in 5 seconds or less. So i was told to
Set a timeout on the connection. It worked. But not all the times.
Sometimes it takes forever. 9 out of 10 times it does work. I still
don't understand why its doing that.
Any ideas?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to