Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8183723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:15:05+00:00 2026-06-07T01:15:05+00:00

I’m building an app that is passing variables to my server through an HttpPost.

  • 0

I’m building an app that is passing variables to my server through an HttpPost. Everything was working well until I updated my Android 2.3 device to Android 4.0 yesterday. After the update the app that I’m working on crashes each time the HttpPost is run. I figured that since the same code was working in Android 2.3 the issue is that it’s just not compatible with the updated system.

What is the best way that I can pass the same variables and still be compatible with Android 2.3 – 4.0? What is the best practice here? I’m fairly new to mobile development. How is my methodology?

HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("MY URL");
 List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
  nameValuePairs.add(new BasicNameValuePair("receiver", "BLAH"));
   try {
    httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
   } catch (UnsupportedEncodingException e) {
    e.printStackTrace();
   }
   try {
    httpClient.execute(httpPost);
   } catch (ClientProtocolException e) {
    e.printStackTrace();
   } catch (IOException e) {
    e.printStackTrace();
   }

Update

Here’s my LogCat

07-06 10:41:25.385: D/DroidGap(6856): DroidGap.onCreate()
07-06 10:42:09.205: I/dalvikvm(7330): Turning on JNI app bug workarounds for target SDK version 10...
07-06 10:42:09.275: D/AndroidRuntime(7330): Shutting down VM
07-06 10:42:09.275: W/dalvikvm(7330): threadid=1: thread exiting with uncaught exception (group=0x40acd210)
07-06 10:42:09.275: E/AndroidRuntime(7330): FATAL EXCEPTION: main
07-06 10:42:09.275: E/AndroidRuntime(7330): java.lang.RuntimeException: Unable to start receiver tellatext.sms.app.SmsReceiver: android.os.NetworkOnMainThreadException
07-06 10:42:09.275: E/AndroidRuntime(7330):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:2229)
07-06 10:42:09.275: E/AndroidRuntime(7330):     at android.app.ActivityThread.access$1500(ActivityThread.java:134)
07-06 10:42:09.275: E/AndroidRuntime(7330):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283)
07-06 10:42:09.275: E/AndroidRuntime(7330):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-06 10:42:09.275: E/AndroidRuntime(7330):     at android.os.Looper.loop(Looper.java:137)
07-06 10:42:09.275: E/AndroidRuntime(7330):     at android.app.ActivityThread.main(ActivityThread.java:4697)
07-06 10:42:09.275: E/AndroidRuntime(7330):     at java.lang.reflect.Method.invokeNative(Native Method)
07-06 10:42:09.275: E/AndroidRuntime(7330):     at java.lang.reflect.Method.invoke(Method.java:511)
07-06 10:42:09.275: E/AndroidRuntime(7330):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
07-06 10:42:09.275: E/AndroidRuntime(7330):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
07-06 10:42:09.275: E/AndroidRuntime(7330):     at dalvik.system.NativeStart.main(Native Method)
07-06 10:42:09.275: E/AndroidRuntime(7330): Caused by: android.os.NetworkOnMainThreadException
07-06 10:42:09.275: E/AndroidRuntime(7330):     at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1119)
07-06 10:42:09.275: E/AndroidRuntime(7330):     at java.net.InetAddress.lookupHostByName(InetAddress.java:441)
07-06 10:42:09.275: E/AndroidRuntime(7330):     at java.net.InetAddress.getAllByNameImpl(InetAddress.java:243)
07-06 10:42:09.275: E/AndroidRuntime(7330):     at java.net.InetAddress.getAllByName(InetAddress.java:220)
07-06 10:42:09.275: E/AndroidRuntime(7330):     at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
07-06 10:42:09.275: E/AndroidRuntime(7330):     at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
07-06 10:42:09.275: E/AndroidRuntime(7330):     at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
07-06 10:42:09.275: E/AndroidRuntime(7330):     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
07-06 10:42:09.275: E/AndroidRuntime(7330):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
07-06 10:42:09.275: E/AndroidRuntime(7330):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
07-06 10:42:09.275: E/AndroidRuntime(7330):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
07-06 10:42:09.275: E/AndroidRuntime(7330):     at tellatext.sms.app.SmsReceiver.onReceive(SmsReceiver.java:114)
07-06 10:42:09.275: E/AndroidRuntime(7330):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:2221)
07-06 10:42:09.275: E/AndroidRuntime(7330): ... 10 more
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T01:15:07+00:00Added an answer on June 7, 2026 at 1:15 am

    You need to run your URL request in background process.

    Here is sample code

    new TestTask().execute();
    

    and

    public class TestTask extends AsyncTask<Void, Void, Void>{
    
        @Override
        protected Void doInBackground(Void... params) {
    
            HttpClient httpClient = new DefaultHttpClient();
            HttpPost httpPost = new HttpPost("MY URL");
             List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
              nameValuePairs.add(new BasicNameValuePair("receiver", "BLAH"));
               try {
                httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
               } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
               }
               try {
                httpClient.execute(httpPost);
               } catch (ClientProtocolException e) {
                e.printStackTrace();
               } catch (IOException e) {
                e.printStackTrace();
               }
            return null;
        }
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I need a function that will clean a strings' special characters. I do NOT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.