Android URL编码器不提供任何值
这是我的代码:Android URL编码器不提供任何值,android,url,Android,Url,这是我的代码: try { data = URLEncoder.encode("product_name", "utf-8")+"="+URLEncoder.encode(params[1], "utf-8"); data +="&"+URLEncoder.encode("product_price", "utf-8")+"="+URLEncoder.encode(params[2], "utf-8"); data
try {
data = URLEncoder.encode("product_name", "utf-8")+"="+URLEncoder.encode(params[1], "utf-8");
data +="&"+URLEncoder.encode("product_price", "utf-8")+"="+URLEncoder.encode(params[2], "utf-8");
data+="&"+URLEncoder.encode("product_flag", "utf-8")+"="+URLEncoder.encode("2", "utf-8");
Log.d("Parth", "data"+data);
new Hiturl().execute(data,url);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.d("Parth", "Error:"+e.getMessage());
}
日志中没有关于它的条目。
甚至没有数据:
如果我的数据是空的,那么我应该至少得到数据:作为我的日志输出,您可能在任何情况下都写入了它,或者检查是否有任何异常否,我没有得到任何形式的错误。我正在尝试通过一个phpserver和POST方法连接android,我正在添加这些值,这可能是因为它抛出了一些异常,它将捕获block。因此日志可能没有执行。确保没有例外。检查params[1]和params[2]是否存在空值。如果您试图使用数据查看logcat:那么您将无法在logcat中获取任何内容,请尝试使用数据或Parth。有时我获取值,有时不获取值。为什么会这样?