title: Android app run on mobile data connection volley
body: <p>How to run Android app on mobile data with volley or asynctask or Advance networking library? I have tried a lot of solution but my Android app not run on mobile data. I have increased volley timeout but not resolve my problem.</p>
  
  <p>Below show my all code with volley library but my problem are not solved with this code also.</p>
  
  <pre><code>firstName = etFirstName.getText().toString();
          lastName = etLastName.getText().toString();
          email = etEmail.getText().toString();
          password = etPassword.getText().toString();
          if (TextUtils.isEmpty(firstName)) {
              etFirstName.setError("Required");
              etFirstName.requestFocus();
          } else if (TextUtils.isEmpty(lastName)) {
              etLastName.setError("Required");
              etLastName.requestFocus();
          } else if (TextUtils.isEmpty(email)) {
              etEmail.setError("Required");
              etEmail.requestFocus();
          } else if (!Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
              etEmail.setError("invalid email");
              etEmail.requestFocus();
          } else if (TextUtils.isEmpty(password)) {
              etPassword.setError("Required");
              etPassword.requestFocus();
          } else {
              etFirstName.setError(null);
              etLastName.setError(null);
              etEmail.setError(null);
              etPassword.setError(null);
              if (isNetworkAvailable()) {
                  RequestQueue queue = Volley.newRequestQueue(getActivity());
                  try {
                      dialog.show();
  
                      // Request a string response from the provided URL.
                      StringRequest stringRequest = new StringRequest(Request.Method.POST, Config.url + "register.php",
                              new Response.Listener&lt;String&gt;() {
                                  @Override
                                  public void onResponse(String result) {
                                      if (!dialog.isCancelled()) {
                                          dialog.dismiss();
                                      }
                                      if (result.equals("email already exist!")) {
                                          Toast.makeText(getActivity(), "Entered email already exist!", Toast.LENGTH_SHORT).show();
                                      } else if (result.equals("Error")) {
                                          Toast.makeText(getActivity(), "Insert Record Error!", Toast.LENGTH_SHORT).show();
                                      } else {
                                          try {
                                              JSONObject response = new JSONObject(result);
                                              String userEmail = response.getString("email");
                                              if (userEmail != null &amp;&amp; !userEmail.isEmpty()) {
                                                  for (int i = 0; i &lt; fragmentManager.getBackStackEntryCount(); i++) {
                                                      fragmentManager.popBackStack();
                                                  }
                                                  String userID = response.getString("id");
                                                  String fbID = response.getString("fb_id");
                                                  String googleID = response.getString("google_id");
                                                  String firstName = response.getString("first_name");
                                                  String lastName = response.getString("last_name");
                                                  String userPass = response.getString("password");
                                                  String userMobile = response.getString("mobile");
                                                  String userLocation = response.getString("location");
                                                  String userDOB = response.getString("dob");
                                                  String userGender = response.getString("gender");
                                                  String posts = response.getString("posts");
                                                  String following = response.getString("following");
                                                  String followers = response.getString("followers");
                                                  String userImagePath = response.getString("image_path");
                                                  sessionManager.createLoginSession(userID, userEmail, fbID, googleID,
                                                          firstName, lastName, userPass, userMobile, userLocation,
                                                          userDOB, userGender, userImagePath, posts, following, followers);
                                                  //fragmentManager.beginTransaction().replace(R.id.framePreLogin, new EnterPhoneFragment()).commit();
                                                  saveSetting(userID);
                                              } else {
                                                  Toast.makeText(getActivity().getApplicationContext(),
                                                          "Profile creation failed. Try again!",
                                                          Toast.LENGTH_SHORT).show();
                                              }
  
                                          } catch (Exception e) {
                                              e.printStackTrace();
                                          }
                                      }
                                  }
                              }, new Response.ErrorListener() {
                          @Override
                          public void onErrorResponse(VolleyError error) {
                              if (!dialog.isCancelled()) {
                                  dialog.dismiss();
                              }
                              if (error instanceof TimeoutError || error instanceof NoConnectionError) {
                                  Toast.makeText(getActivity(), "Network Connection Timeout!", Toast.LENGTH_LONG).show();
                              } else if (error instanceof AuthFailureError) {
                                  Toast.makeText(getActivity(), "Auth failure error!", Toast.LENGTH_LONG).show();
                              } else if (error instanceof ServerError) {
                                  Toast.makeText(getActivity(), "Server error!", Toast.LENGTH_LONG).show();
                              } else if (error instanceof NetworkError) {
                                  Toast.makeText(getActivity(), "network error!", Toast.LENGTH_LONG).show();
                              } else if (error instanceof ParseError) {
                                  Toast.makeText(getActivity(), "Parsing error!", Toast.LENGTH_LONG).show();
                              }
                          }
  
                      }) {
                          @Override
                          protected Map&lt;String, String&gt; getParams() throws AuthFailureError {
                              Map&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
                              params.put("first_name", firstName);
                              params.put("last_name", lastName);
                              params.put("email", email);
                              params.put("password", password);
                              String firebaseRegistrationId = sessionManager.getFirebaseToken();
                              params.put("firebase_registration_id", firebaseRegistrationId);
                              return params;
                          }
  
                          @Override
                          public Map&lt;String, String&gt; getHeaders() throws AuthFailureError {
                              Map&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
                              params.put("Content-Type", "application/x-www-form-urlencoded");
                              return params;
                          }
                      };
                      stringRequest.setRetryPolicy(new DefaultRetryPolicy(
                              MY_SOCKET_TIMEOUT_MS,
                              DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
                              DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
                      // Add the request to the RequestQueue.
                      queue.add(stringRequest);
                  } catch (Exception ex) {
                      ex.printStackTrace();
                  }
              } else {
                  Toast.makeText(getActivity().getApplicationContext(), "Network not available. Try again!", Toast.LENGTH_SHORT).show();
              }
          }
  </code></pre>