Using Volley trying to login, showing error Volley: null, code: null

I can get the link from http://www.androidhive.info/2016/02/android-push-notifications-using-gcm-php-mysql-realtime-chat-app-part-3/ to complete the chat app. The tutorial was using Volley

login and I found it shows Volley error: null, code: null

like this:

03-24 01:04:43.141 2523-5531/tw.idv.mogoflash.gcmadvance1 E/LoginActivity: params: {email=morton9487@gmail.com, name=Morton}
03-24 01:04:45.639 2523-5531/tw.idv.mogoflash.gcmadvance1 E/LoginActivity: params: {email=morton9487@gmail.com, name=Morton}
03-24 01:04:46.796 2523-5531/tw.idv.mogoflash.gcmadvance1 D/Volley: [116] BasicNetwork.logSlowRequests: HTTP response for request=<[ ] http://10.0.2.2/gcm_chat/v1/user/login 0x1e7db229 NORMAL 1> [lifetime=3655], [size=0], [rc=404], [retryCount=1]
03-24 01:04:46.796 2523-5531/tw.idv.mogoflash.gcmadvance1 E/Volley: [116] BasicNetwork.performRequest: Unexpected response code 404 for http://10.0.2.2/gcm_chat/v1/user/login
03-24 01:04:46.797 2523-2523/tw.idv.mogoflash.gcmadvance1 E/LoginActivity: Volley error: null, code: com.android.volley.NetworkResponse@2ecd3e18
03-24 01:04:46.800 2523-2523/tw.idv.mogoflash.gcmadvance1 D/Volley: [1] Request.finish: 3676 ms: [ ] http://10.0.2.2/gcm_chat/v1/user/login 0x1e7db229 NORMAL 1
03-24 01:04:46.881 2523-2650/tw.idv.mogoflash.gcmadvance1 V/RenderScript: 0xaea5dc00 Launching thread(s), CPUs 2

      

This is my URL setup:

public static final String BASE_URL = "http://10.0.2.2:8080/gcm_chat/v1/user/login";

      

I have no idea about this volleyball error, why is it showing me zero?

I tried to change my url like:

public static final String BASE_URL = "http://Webserver/gcm_chat/v1/user/login";

and

public static final String BASE_URL = "http://localhost/gcm_chat/v1/user/login";

they don't work for me.

I checked in MySQL that the user Morton existed.
Can anyone tell me why? Any help would be greatly appreciated.

If I test localhost by postman it works enter image description here

+3


source to share


1 answer


Check your Volley Request.method

.see if Request.Method.POST

, if this part is wrong in your request, the response will also be 404.

I mean this part below



                                       //check your Request method
StringRequest userReq = new StringRequest(Request.Method.GET,
            YOUR_URL, new Response.Listener<String>()

      

+1


source







All Articles