如何编码和解码或解析字符串,使其读取为url?
我尝试了两件事:
但响应显示错误400
在这里,我附上了代码,请看下面的内容
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
try {
progressDialog.setMessage("Mencari...");
showDialog();
jobList.clear();
String queryEncode = AppConfig.URL_GETJOBS + Uri.encode(query);
//String queryEncode = URLEncoder.encode(query, "UTF-8");
//String queryDecode = AppConfig.URL_GETJOBS + URLDecoder.decode(queryEncode, "UTF-8");
Log.d(TAG, "onQueryTextSubmit: " + getJobs(queryEncode));
getJobs(queryEncode);
homeRecyclerViewAdapter.notifyDataSetChanged();
hideDialog();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});
这里响应错误400 on logd:(https://i.stack.imgur.com/ZjbgY.png)
邮差200的回复OK(成功)(qazxsw poi)
答案是您无法使用ip 192.168.43.142访问该地址,因为这是您计算机的本地主机。
https://i.stack.imgur.com/YER6K.png
如果你使用邮递员做同样的事情,你真的在你已经访问过的同一台电脑上做。