Failed to connect to server - Unable to resolve host "play.googleapis.com": No address associated with hostname

0

I'm creating an app in Android Studio that will send information to a web service that will insert the data into the database.

But when I press to insert the data, the program returns this error:

Failed to connect to server: java.net.UnknownHostException: Unable to resolve host "play.googleapis.com": No address associated with hostname

MainActivity:

public class MainActivity extends AppCompatActivity {

String inserturl = "http://localhost/inserirDados.php";
EditText nome;
EditText endereco;
Button inserir;
Button selecionar;
RequestQueue rq;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    nome = (EditText) findViewById(R.id.txtNome);
    endereco = (EditText) findViewById(R.id.txtEndereco);
    inserir = (Button) findViewById(R.id.btEnviarDados);
    selecionar = (Button) findViewById(R.id.btMostrarDados);

    rq = Volley.newRequestQueue(getApplicationContext());

    inserir.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            inserir();
        }
});

}

public void inserir(){
    StringRequest request = new StringRequest(Request.Method.POST, inserturl, new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {

        }
    }, new ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {

        }
    }) {
        @Override
        protected Map<String, String> getParams() throws AuthFailureError {

            Map<String, String> parametros = new HashMap<String, String>();
            parametros.put("nome", nome.getText().toString());
            parametros.put("enredeco", endereco.getText().toString());
            return parametros;
        }
    };
    rq.add(request);

}
}

Remembering that my AndroidManifest.xml has the following permissions:

 <uses-permission android:name="android.permission.INTERNET"/>
 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Can anyone help me understand what I need to do to insert data from an app into an external database?

    
asked by anonymous 07.09.2016 / 01:39

0 answers