I am creating an Android app that sends data to a Firebase server. What I am unable to do is get the public IP address that is being used to connect to the Firebase server. When the user is on 3G, the code below gives the private IP which is useless since it changes every time the user connects to 3G on his mobile data. Hence, I want to get the public IP address that is being used to make a request to the Firebase server
If I am not wrong, the code below gives me the private IP address.
WifiManager wifiMan = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInf = wifiMan.getConnectionInfo();
int ipAddress = wifiInf.getIpAddress();