尝试使用截击将android设备连接到wampserver(本地主机)时失败
我正在尝试将我的Android设备连接到本地主机ie wampserver 使用android截击 这是我的代码:尝试使用截击将android设备连接到wampserver(本地主机)时失败,android,android-volley,Android,Android Volley,我正在尝试将我的Android设备连接到本地主机ie wampserver 使用android截击 这是我的代码: public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activi
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);
}
}
public类MainActivity扩展了AppCompatActivity{
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
字符串url=”http://192.16x.x.xxx/folderName/ClutchTester.php";
JsonObjectRequest=newJSONObjectRequest(request.Method.GET,url,null,new Response.Listener()){
@凌驾
公共void onResponse(JSONObject响应){
Toast.makeText(getApplicationContext(),response.toString(),Toast.LENGTH_LONG.show();
}
},new Response.ErrorListener(){
@凌驾
公共无效onErrorResponse(截击错误){
Toast.makeText(getApplicationContext(),error.toString(),Toast.LENGTH_LONG.show();
}
});
newRequestQueue(getApplicationContext()).add(请求);
}
}
Toast说AuthFailureError。我在这里使用的IP地址是IPv4地址。有人知道我为什么会犯这个错误,以及我如何解决这个问题吗
尝试将固定ip分配给电脑,而不是自动获取
完成后
- 现在你的路由器知道在你的pc上把这些数据包发送到哪里,剩下的数据包由你的wampserver处理
- 将url ip更改为您在代码中为电脑修复的ip
- 现在你的路由器知道在你的pc上把这些数据包发送到哪里,剩下的数据包由你的wampserver处理
- 将url ip更改为您在代码中为电脑修复的ip