Sure... check for the internet connection before you bother building the
URL and trying to connect :).
public boolean IsConnectedToNetwork(Context context)
{
ConnectivityManager conManager = (ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo[] allNetworkInfo = conManager.getAllNetworkInfo();
NetworkInfo currNetworkInfo;
boolean anythingConnected = false;
for (int i = 0; i < allNetworkInfo.length; i++)
{
currNetworkInfo = allNetworkInfo[i];
if (currNetworkInfo.getState() == NetworkInfo.State.CONNECTED)
anythingConnected = true;
}
return anythingConnected;
}
On 31/07/2010 4:29 AM, tarek attia wrote:
Hi all,
I have a problem in my code ,runs on the emulator very well,but on my
T-mobile G1 doesn't time out .Code snippet is below :-
URL myURL = new URL(uriBuilder.toString());
URLConnection myConnection = myURL.openConnection();
myConnection.setConnectTimeout(40000);
so when no internet connection it doesn't time out at all !!!!!
any Idea ?
--
tarek
--
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
--
Sincerely,
Brad Gies
-----------------------------------------------------------------------
Bistro Bot - Bistro Blurb
http://www.bgies.com
http://www.bistroblurb.com
http://www.ihottonight.com
-----------------------------------------------------------------------
Never doubt that a small group of thoughtful, committed people can
change the world. Indeed. It is the only thing that ever has - Margaret Mead
--
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