The exception you receive indicates a name resolution problem (getting the IP address abovestress.com from the DNS server). This is probably due to the fact that your network is down.
A simple snippet to check if a network connection is enabled, where Context ctx
is the action context:
public boolean checkConnection(Context ctx) { ConnectivityManager conMgr = (ConnectivityManager)ctx.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo i = conMgr.getActiveNetworkInfo(); if (i == null) return false; if (!i.isConnected()) return false; if (!i.isAvailable()) return false; return true; }
EDIT:
If the network is not your problem, look here and here.
you may need to add (besides android.permission.INTERNET
) other permissions:
android.permission.ACCESS_NETWORK_STATE android.permission.READ_PHONE_STATE
and / or
try { InetAddress i = InetAddress.getByName(URLName); } catch (UnknownHostException e1) { e1.printStackTrace(); }
EDIT 2: And as others have noted, the uses-permission
element is inside the manifest
element, not the application
element
source share