Simply,
Its a mistake in the url, just fix it.
"www.google.com" you have 4 w in your URL ...
And add Use-Permission <uses-permission android:name="android.permission.INTERNET">
in the manifest file of your Android application.
It is right.
addr = InetAddress.getByName("www.google.com");
EDIT: Use AsyncTaskfor networking
String netAddress = null;
try
{
netAddress = new NetTask().execute("www.google.com").get();
}
catch (Exception e1)
{
e1.printStackTrace();
}
And this NetTask class ..
public class NetTask extends AsyncTask<String, Integer, String>
{
@Override
protected String doInBackground(String... params)
{
InetAddress addr = null;
try
{
addr = InetAddress.getByName(params[0]);
}
catch (UnknownHostException e)
{
e.printStackTrace();
}
return addr.getHostAddress();
}
}