Other Threads
1. Problem retrieving the body from a http post message
Hi all,
First i'll tell you what i am doing:
i want my andorid app to update a database located on a server.
to do this, from my android app i send an http post message to a
servlet, which updates the DB.
the post message contains an xml file on his body.
the problem comes when i try to get that body on the servlet.
here is the android code:
public String executeHttpPost() throws Exception{
BufferedReader in = null;
String result="";
try {
String xml = XMLHelper.crearXML(results);
HttpClient client = new DefaultHttpClient();
HttpPost request = new
HttpPost("http://192.168.0.10:8080/
ServidorWebSupervisorV1/ServletSupervisorV1");
List<NameValuePair> postParamaters = new
ArrayList<NameValuePair>();
postParamaters.add(new BasicNameValuePair("XML", xml));
UrlEncodedFormEntity formEntity = new
UrlEncodedFormEntity(postParamaters);
request.setHeader("Host", "EM1");
request.setHeader("Content-Type","application/x-www-form-
urlencoded");
request.setEntity(formEntity);
String f = EntityUtils.toString(request.getEntity());
HttpResponse response = client.execute(request);
in = new BufferedReader(new
InputStreamReader(response.getEntity().getContent()));
StringBuffer sb = new StringBuffer("");
String line = "";
String NL = System.getProperty("line.separator");
while((line = in.readLine())!= null)
sb.append(line + NL);
in.close();
result = sb.toString();
}
catch(Exception e){
String m = e.getMessage();
}
return result;
}
here is my servlet code:
PrintWriter out = response.getWriter();
System.out.println("tamano: "+request.getContentLength());
System.out.println("metodo:"+request.getMethod());
System.out.println("path:"+request.getContextPath());
System.out.println("address:"+request.getRemoteAddr());
String body="", aux="";
BufferedReader reader = request.getReader();
while((aux = reader.readLine())!=null)
body = body + aux + "\n";
System.out.println("metodo:"+request.getMethod());
InputSource source = new InputSource(reader);
try {
SAXParserFactory spf = SAXParserFactory.newInstance();
javax.xml.parsers.SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
XMLHandler handler = new XMLHandler();
xr.setContentHandler(handler);
xr.parse(new InputSource(request.getReader()));
} catch (Exception e) {
e.printStackTrace();
}
thank you all
--
2. Continue playing after leaving the media player
Hi,
I launch the Media Player to play a mp3 file the usual way:
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), mimeType);
try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
.....
}
Leaving the Media Player using the Back button stops the playback.
How can I ensure that the Media Player continues playing.
Regards
manayv
--
3. Inconsistent Alarm Behavior
4. Scala, Android, Eclipse - not including Scala jar?
5. Broadcast Message on GPS turn on/off??
6. How can I override URLs of the resources fetched by the WebKit
7. JUnit failing with warning - ""test class not found in selected project"