2011-06-10 45 views
1

我有一個類,在我的應用程序時,我可以發送到servelet instatianted。如何從android手機發送對象到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(); 

會如何我去發送日期對象和位圖對象?

回答

相關問題