0

I followed this link Android get external IP . I am connecting to this website http://www.whatismyip.org/ to get my IP address, however, it keep returning a length of -1.

Any idea why? I am able to open up this site using my browser and it returns my external IP. I am unable to use other websites as they return a proxy IP or some other IP...

Community
  • 1
  • 1
humansg
  • 735
  • 3
  • 12
  • 30

1 Answers1

0

if you are going with that service. Don't check for length cause they don't provide that info but go straight for fetching the ip

so forget about if condition and go for it like this

                entity.getContentLength();
                String str = EntityUtils.toString(entity);
                ip.setText(str);
Win Myo Htet
  • 5,377
  • 3
  • 38
  • 56
  • Ok, then what is the purpose of them checking the length? I thought it is used to check if there is any content body... – humansg Mar 31 '12 at 09:17
  • the service you use purposely stripped everything to reduce the package load. it is their designed to reduce the traffic load. it is not a bug. – Win Myo Htet Mar 31 '12 at 14:59