I want to get ip adress from url in android.How is it possible?
Asked
Active
Viewed 3,631 times
1 Answers
2
Do this
InetAddress address = InetAddress.getByName("www.google.com");
String ip = address.getHostAddress();
And make sure you have internet permission.

Robert
- 2,357
- 4
- 25
- 46
-
I tried that codes.first line is working but second line is not working. – user3096003 Jul 18 '14 at 11:42
-
What do you mean by not working? Do you get an error? – Robert Jul 18 '14 at 12:00
-
yes, it throws exception. – user3096003 Jul 18 '14 at 12:03
-
try { InetAddress address = InetAddress.getByName("www.google.com"); String ip = address.getHostAddress(); } catch (Exception e) { } – user3096003 Jul 18 '14 at 12:03
-
can you send an example. harunkaraca19@yandex.com.tr on facebook – user3096003 Jul 18 '14 at 12:10