java - httpClient.execute does not show any response. -
java - httpClient.execute does not show any response. -
public class mainactivity extends actionbaractivity { public bitmap bitmap; public static string exsistingfilename; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); log.d("tag", "first log message"); inputstream is=getresources().openrawresource(r.drawable.ic_launcher); bitmap = bitmapfactory.decodestream(is); //this gets image imageview myimageview = (imageview)findviewbyid(r.id.myimageview); myimageview.setimagebitmap(bitmap); seek { senddata(null); } grab (exception e) { e.printstacktrace(); } } public void senddata(string[] args) throws exception { seek { httpclient httpclient = new defaulthttpclient(); httpcontext localcontext = new basichttpcontext(); httppost httppost = new httppost("http://localhost/xampp/uploadtoserver.php"); multipartentity entity = new multipartentity(httpmultipartmode.browser_compatible); log.d("tag", "second log message"); // format of image compressed - 640 x 480; bitmap bmpcompressed = bitmap.createscaledbitmap(bitmap, 640, 480, true); bytearrayoutputstream bos = new bytearrayoutputstream(); log.d("tag", "third log message"); bmpcompressed.compress(compressformat.jpeg, 100, bos); log.d("tag", "fourth log message"); byte[] info = bos.tobytearray(); entity.addpart("myparam", new stringbody("my value")); entity.addpart("myimage", new bytearraybody(data, "temp.jpg")); log.d("tag", "fifth log message"); httppost.setentity(entity); log.d("tag", "sixth log message"); httpresponse response = httpclient.execute(httppost,localcontext); log.d("tag", "seventh log message"); bufferedreader reader = new bufferedreader(new inputstreamreader( response.getentity().getcontent(), "utf-8")); string sresponse = reader.readline(); } grab (exception e) { system.out.println(e.getclass().getname()); log.v("myapp", "some error came up"); } }
}
it not give value in "response". next logcat info related activity.
06-22 03:31:39.273: d/tag(2889): first log message 06-22 03:31:39.289: d/tag(2889): sec log message 06-22 03:31:39.414: d/tag(2889): 3rd log message 06-22 03:31:39.539: d/tag(2889): 4th log message 06-22 03:31:39.546: d/tag(2889): 5th log message 06-22 03:31:39.546: d/tag(2889): 6th log message 06-22 03:31:41.304: i/system.out(2889): org.apache.http.conn.httphostconnectexception 06-22 03:31:41.304: d/tag(2889): error came up
java android apache http debugging
Comments
Post a Comment