开发者

How can I pass non String parameters with HttpPost?

I use BasicNameValuePair class fo开发者_如何学Pythonr passing String parameters with HttpPost in my Android application. How can I pass non String parameters like Double, Byte Array etc?

Thanks in advance


Short answer: You can't. Not really.

Long answer: The stuff that can be easily converted to a string you can just convert to a string (.toString) and parse (Double.parseStr()).

Common practice for byte arrays is to encode them in - for instance - Base64. Android docs here


Convert them to strings?

String.valueOf();


parse it as a string

whateverparameter.toString()


You can convert the value to String:

final Double myDouble = new Double("12.35");
new BasicNameValuePair(MY_DOUBLE_PARAM, myDouble.toString());
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜