简体   繁体   中英

AuthFailure while trying to connect android device to wampserver(localhost) using volley

I am trying to connect my Android device to localhost ie wampserver using android volley

This is my code:

public class MainActivity extends AppCompatActivity {

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

      String url = "http://192.16x.x.xxx/folderName/ClutchTester.php";


      JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {

            Toast.makeText(getApplicationContext(),response.toString(),Toast.LENGTH_LONG).show();
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Toast.makeText(getApplicationContext(),error.toString(),Toast.LENGTH_LONG).show();
        }
    });
    Volley.newRequestQueue(getApplicationContext()).add(request);
    }
}

Toast says AuthFailureError . the IP address I am using here is an IPv4 Address. Does anybody know why I am getting this error and how I can solve this?

Try to assign fixed ip to your pc instead of get automatically

When you are done

  • Now your router know where to send those packets if get and At your pc your wampserver will handle rest.

Reason : The ip you are using is probably not found by your router since ip is automatically assigned.

Don't forget

  • Change your url ip with the ip you have fixed for your pc in your code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM