I made a solution to check if the client uses proxy, before it was 2 methods, one to get the ip and one to test it. This way you already do both.
RequestQueue queue;
StringRequest proxyRequest, ipRequest;
String url = null;
queue = Volley.newRequestQueue(this);
String url_ip = "https://api.ipify.org";
ipRequest = new StringRequest(Request.Method.GET, url_ip,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
url = "http://check.getipintel.net/check.php?ip="+
response+"&contact="+user.getEmail()+"&flags=b";
proxyRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
float re = 0f;
try {
re = Float.valueOf(response);
} catch (NumberFormatException e){
Crashlytics.logException(e);
re = 0;
}
if(re > 0.995){
Toast.makeText(getApplicationContext(), "Proxy/VPN/Bots não são permitidos no app!", Toast.LENGTH_SHORT).show();
}
else {
Intent i = new Intent(getApplicationContext(), MainActivity.class);
startActivity(i);
finish();
progressBar.setVisibility(View.GONE);
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(), "Erro: " + error.getMessage(), Toast.LENGTH_SHORT).show();
progressBar.setVisibility(View.GONE);
Intent in = new Intent(getApplicationContext(), SplashActivity.class);
startActivity(in);
finish();
}
});
queue.add(proxyRequest);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(), "Erro: " + error.getMessage(), Toast.LENGTH_SHORT).show();
}
});
queue.add(ipRequest);
This way works with me quiet, this is to check if the client is proxy, but if you give an adapted you can only return the IP string.
Please see which error is shown in your terminal and post here
– Alysson Chicó