Note that there are some explanatory texts on larger screens.

plurals
  1. POI'm trying to figure out a way to have an inputstream from one class be parsed in a different class
    primarykey
    data
    text
    <p>I am fairly new to Android and I like to have an inputstream be transferred from one class to another. Basically, I am trying to get a geocoded location to be sent to a server and a response to be sent to the other class for parsing.</p> <p>here is a snippet of code I have so far for the httppost and inputstream response:</p> <p>Location1.java</p> <pre><code>private void updateWithNewLocation(Location location) { if (location != null) { double lat = location.getLatitude(); String lat1 = Double.toString(lat); double lng = location.getLongitude(); String lng1 = Double.toString(lng); HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://..."); try { List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(2); </code></pre> <p>nameValuePairs.add(new BasicNameValuePair("lat", lat1)); nameValuePairs.add(new BasicNameValuePair("lng", lng1)); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));</p> <pre><code> HttpResponse response = httpclient.execute(httppost); InputStream is = response.getEntity().getContent(); </code></pre> <p>BufferedInputStream bis = new BufferedInputStream(is); ByteArrayBuffer baf = new ByteArrayBuffer(20);</p> <pre><code>int current = 0; while((current = bis.read()) != -1){ baf.append((byte)current); } </code></pre> <p>Here is a snippet from the other class I want to have the inputstream parsed in... There already was an inputsream in this class and I was trying to figure out how to replace it with the other stream from the other class.</p> <p>parser1.java</p> <pre><code> //I already have an inputstream here and this is where I want to inject the other class inputstream InputStream in = httpConnection.getInputStream(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); // parse the feed Document dom = db.parse(in); Element docEle = dom.getDocumentElement(); ... </code></pre> <p>Any help would be much appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload