On Tue, Oct 12, 2010 at 3:51 PM, Capt Spaghetti <[email protected]> wrote:
>                HttpPost httppost = new HttpPost("graborginfo.php");

That is not a valid URL.

>                HttpResponse response = httpclient.execute(httppost);
>                HttpEntity entity = response.getEntity();
>                InputStream is = entity.getContent();
>        }catch(Exception e){
>                Log.e("log_tag", "Error in http connection
> "+e.toString());
>        }
>        //convert response to string
>        try{
>                        InputStreamReader is = new 
> InputStreamReader(System.in);
>                BufferedReader reader = new BufferedReader(is);
>                StringBuilder sb = new StringBuilder();
>                String line = null;
>                while ((line = reader.readLine()) != null) {
>                        sb.append(line + "\n");
>                }
>                is.close();
>
>                result=sb.toString();
>        }catch(Exception e){
>                Log.e("log_tag", "Error converting result
> "+e.toString());
>        }

For this, I recommend using the BasicResponseHandler pattern:

http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientWithResponseHandler.java

(or http://bit.ly/lCVgZ if that URL is too long)

> The LOGCAT output for the error is as follows:
> =====================
> 10-12 11:14:08.199: INFO/global(233): Default buffer size used in
> BufferedReader constructor. It would be better to be explicit if an 8k-
> char buffer is required.
> 10-12 11:14:20.460: ERROR/log_tag(233): Error parsing data
> org.json.JSONException: A JSONArray text must start with '[' at
> character 0 of

You may want to dump the value you are trying to parse as JSON to
LogCat, as it is not what you think it is.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android 2.2 Programming Books: http://commonsware.com/books

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to