The code pasted below has been successfully tested on several phones 
running Gingerbread, ICS, and Jelly Bean.  However when testing on a 
friends Samsung 4GLTE model SCH-1200 (verison) the code fails.  
The post throws an exception and in the Catch, the log throws a null 
Pointer exception.

I examined the contents of the myPost and it all looks valid.

What could be wrong with this phone?  Could the owner have something turned 
off that might cause this?  The phone is not in airplane mode

This code is running in an Activity.
Thanks Gary

   private String PostToCloudService(URL url, String entityString)
     {
      String retstr = "";
      try
      {
     HttpResponse response = null;
     HttpParams myParams = new BasicHttpParams();
     HttpConnectionParams.setConnectionTimeout(myParams,5000);
     HttpConnectionParams.setSoTimeout(myParams, 5000);
     HttpClient httpclient = new DefaultHttpClient(myParams);
      
     HttpPost myPost = new HttpPost(url.toString());
     StringEntity se = new StringEntity(entityString);
     myPost.setEntity(se);
     myPost.setHeader("Accept", "application/json");
     myPost.setHeader("Content-type", "text/plain");
     
     Log.w(getClass().getName(), "now executing post" + myPost);
     
     response = httpclient.execute(myPost); <-----THIS THROWS EXCEPTION
     
     BufferedReader rd = new BufferedReader(new 
InputStreamReader(response.getEntity().getContent()));
            String line = "";
            while ((line = rd.readLine()) != null)
            {
           Log.w(getClass().getName(), "response from Server is " + line);
           retstr = line;
            } 
      
      }
      catch (Exception e)
      {
       Log.w(getClass().getName(), e.getMessage().toString());  <---THIS 
GETS NULLPOINTER EXCEPTOION
       retstr = "error  " + e.getMessage().toString();
      }
      
        return retstr;
     } 

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to