gpt4 book ai didi

java - 如何将对象从android手机发送到servlet?

转载 作者:行者123 更新时间:2023-12-01 05:44:18 24 4
gpt4 key购买 nike

当我可以将其发送到servelet时,我的应用程序中就有一个类。

public class PinnedVehicle {

private String userId;
private Location location;
private Date timeToReturn;
private String notes;
private Bitmap photo;
}


现在,对于位置,我只真正需要经度和纬度,但是如何将其发送到服务器

目前我所要做的只是

 String URL = "xxxx";
String result = "";
String deviceId = "xxxxx" ;
String q = "?lat="+location.getLatitude()+"&lng="+location.getLongitude()" //and so on for all strings and integers

HttpClient httpclient = new DefaultHttpClient();
HttpGet request = new HttpGet(URL+q);
request.addHeader("deviceId", deviceId);
ResponseHandler<String> handler = new BasicResponseHandler();
try {
result = httpclient.execute(request, handler);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
httpclient.getConnectionManager().shutdown();


我将如何发送日期对象和位图对象?

最佳答案

您应该检查this thread

关于java - 如何将对象从android手机发送到servlet?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6308722/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com