Java Android Studio - Recover IP from device

Asked

Viewed 80 times

0

Good morning, friends! Does anyone know how I can recover ip from an android device? I got some codes, but only to recover the wifi ip. I need this ip, because I am working on an ad application, and in order not to keep counting several clicks to the advertiser, I would have to block this ip temporarily. Thanks in advance!

1 answer

0

You can use a Webservice as AWS

import java.net.*;
import java.io.*;

URL meuIP = new URL("http://checkip.amazonaws.com");
BufferedReader in = new BufferedReader(new InputStreamReader(meuIP.openStream()));

String ip = in.readLine(); //você terá seu IP como uma String
System.out.println(ip);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.