gpt4 book ai didi

android - 使用 Volley 尝试登录显示 Volley error : null, code: null

转载 作者:可可西里 更新时间:2023-11-01 08:39:19 26 4
gpt4 key购买 nike

我引用了http://www.androidhive.info/2016/02/android-push-notifications-using-gcm-php-mysql-realtime-chat-app-part-3/完成一个聊天应用程序。该教程使用 Volley 登录,我发现它显示 Volley error: null, code: null ,就像这样:

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

这是我的 url 设置:

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

我不知道这个 volley 错误,为什么它显示为 null?

我曾尝试更改我的网址:

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

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

他们对我不起作用。

我检查了MySQL,用户Morton存在。
谁能告诉我为什么?任何帮助,将不胜感激。

如果我通过 postman 测试本地主机,它会工作 enter image description here

最佳答案

检查你的 Volley Request.method,看看是否是 Request.Method.POST ,如果这部分你的请求方法错误,响应也会是 404。

我的意思是下面这部分

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

关于android - 使用 Volley 尝试登录显示 Volley error : null, code: null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42966554/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com