title: java.net.SocketTimeoutException: failed to connect to /10.0.2.2 (port 8080) after 10000ms
body: <p>I am trying to connect my android app with my own Rest Service. But i received this error:</p>
  
  <pre><code>java.net.SocketTimeoutException: failed to connect to /10.0.2.2 (port 8080) after 10000ms
  </code></pre>
  
  <p>This is my code:</p>
  
  <pre><code>public class LoginActivity extends AppCompatActivity implements OnClickListener {
  
      Button login, exit, back;
      TextView result;
      OkHttpClient client;
      MediaType JSON;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_login);
  
          client = new OkHttpClient();
          JSON = MediaType.parse("application/json; charset=utf-8");
      }
  
      public class GetTask extends AsyncTask {
  
          private Exception exception;
  
          @Override
          protected Object doInBackground(Object[] params) {
              try {
                  String getResponse = get("http://10.0.2.2:8080/ServicioRestTFG/rest/UsuariosServicesRs/");
                  return getResponse;
              } catch (Exception e) {
                  this.exception = e;
                  return null;
              }
          }
  
          public String get(String url) throws IOException {
              Request request = new Request.Builder().url(url).build();
              Response response = client.newCall(request).execute();
              return response.body().string();
          }
      }
  
      @Override
      public void onClick(View v) {
          GetTask task = new GetTask();
          task.execute();
      }
  </code></pre>
  
  <p>I have no idea what is the problem. I read that one solution is increase timeout but this not my solution becasuse i try it and it doesnt work for me. </p>