@Override protected RaceStatisticsListDTO doInBackground(Void... params) { try { final String url = getString(R.string.base_uri) + Constants.updateracestatus; // Set the Accept header for "application/json" or "application/xml" HttpHeaders requestHeaders = new HttpHeaders(); List<MediaType> acceptableMediaTypes = new ArrayList<MediaType>(); acceptableMediaTypes.add(MediaType.APPLICATION_XML); requestHeaders.setAccept(acceptableMediaTypes); String username = AppSettings.getServer_username(); String password = AppSettings.getServer_password(); MultiValueMap<String, String> requestData = new LinkedMultiValueMap<String, String>(); requestData.add("username", username); requestData.add("password", password); requestData.add("raceid", "" + raceId); // Populate the headers in an HttpEntity object to use for the request HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<MultiValueMap<String, String>>(requestData, requestHeaders); // Create a new RestTemplate instance RestTemplate restTemplate = new RestTemplate(); // Perform the HTTP GET request ResponseEntity<RaceStatisticsListDTO> responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, RaceStatisticsListDTO.class); // Return the state from the ResponseEntity RaceStatisticsListDTO liste = responseEntity.getBody(); return liste; } catch (Exception e) { Utilities.LogError("receiveUpdate", e); } return null; }
@Override protected String doInBackground(Void... params) { try { final String url = getString(R.string.base_uri) + Constants.addracelocation; // Set the Accept header for "application/json" or "application/xml" HttpHeaders requestHeaders = new HttpHeaders(); List<MediaType> acceptableMediaTypes = new ArrayList<MediaType>(); acceptableMediaTypes.add(MediaType.MULTIPART_FORM_DATA); requestHeaders.setAccept(acceptableMediaTypes); String username = AppSettings.getServer_username(); String password = AppSettings.getServer_password(); MultiValueMap<String, String> requestData = new LinkedMultiValueMap<String, String>(); requestData.add("username", username); requestData.add("password", password); requestData.add("raceid", "" + raceId); requestData.add("longitude", "" + longitude); requestData.add("latitude", "" + latitude); requestData.add("altitude", "" + altitude); // Populate the headers in an HttpEntity object to use for the request HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<MultiValueMap<String, String>>(requestData, requestHeaders); // Create a new RestTemplate instance RestTemplate restTemplate = new RestTemplate(); // Perform the HTTP GET request ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class); return responseEntity.getBody(); } catch (Exception e) { Utilities.LogError("sending location infos", e); } return null; }