运行我的应用程序..我有这个错误,说错误的URL ...我尝试从网站上复制粘贴有“http://”,但它仍然无法工作,然后我尝试了“https:// “同样......我的应用程序仍无效。
这是我的registerRequest代码,其中我的网址是(这是原始网址):
public class RegisterRequest extends StringRequest {
private static final String REGISTER_REQUEST_URL = "mypetcareapp.xyz/Register.php";
private Map<String, String> params;
public RegisterRequest(String name, String username, String emailaddress, String password, Response.Listener<String> listener){
super(Method.POST, REGISTER_REQUEST_URL, listener, null);
params = new HashMap<>();
params.put("Name", name);
params.put("Username", username);
params.put("EmailAddress", emailaddress);
params.put("Password", password);
}
@Override
public Map<String, String> getParams() {
return params;
}
}
这是我的logcat:
[52387] NetworkDispatcher.run: Unhandled exception java.lang.RuntimeException: Bad URL mypetcareapp.xyz/Register.php
java.lang.RuntimeException: Bad URL mypetcareapp.xyz/Register.php
at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:144)
at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:112)
Caused by: java.net.MalformedURLException: Protocol not found: mypetcareapp.xyz/Register.php
at java.net.URL.<init>(URL.java:176)
at java.net.URL.<init>(URL.java:125)
at com.android.volley.toolbox.HurlStack.performRequest(HurlStack.java:102)
at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:96)
at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:112)
答案 0 :(得分:2)
您的logcat状态为"Caused by: java.net.MalformedURLException: Protocol not found: mypetcareapp.xyz/Register.php"
。
请在网址前加上正确的协议(http://或https://)。