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

  • Home
  • SEARCH
  • 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 8405851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:56:21+00:00 2026-06-09T22:56:21+00:00

I have look through most of the q/a here at Stackoverflow and through the

  • 0

I have look through most of the q/a here at Stackoverflow and through the internet for the answer before I decided to reach out here..

I’m trying call a php page on my website and I keep getting this error when the httpclient.execute is called:

08-19 12:42:33.889: E/AndroidRuntime(5340): FATAL EXCEPTION: main 08-19 12:42:33.889:
E/AndroidRuntime(5340): java.lang.IllegalStateException: Could not execute method of the activity 08-19 12:42:33.889: E/AndroidRuntime(5340):
at android.view.View$1.onClick(View.java:3046)

So I read through some post and one thing I made sure that I had the

<uses-permission android:name="android.permission.INTERNET" />

added to my manifest (which I do) below is a snip-it I got from the internet that I call from a button onclick event:

 HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://mywebsite/scripts/test.php");

        try {
            // Add your data
            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(3);
            nameValuePairs.add(new BasicNameValuePair("function", "1"));
            nameValuePairs.add(new BasicNameValuePair("user", "username"));
            nameValuePairs.add(new BasicNameValuePair("pass", "123"));
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

            // Execute HTTP Post Request
            HttpResponse response = httpclient.execute(httppost);
            Log.e("log_tag", response.toString());


        } catch (ClientProtocolException e) {
             Log.e("log_tag", e.toString());
        } catch (IOException e) {
            Log.e("log_tag", e.toString());
        }

full log:

08-19 12:42:16.365: I/System.out(5340): Sending WAIT chunk
08-19 12:42:16.365: W/ActivityThread(5340): Application com.example.equinetravels is waiting for the debugger on port 8100...
08-19 12:42:16.373: I/dalvikvm(5340): Debugger is active
08-19 12:42:16.373: I/System.out(5340): Debugger has connected
08-19 12:42:16.373: I/System.out(5340): waiting for debugger to settle...
08-19 12:42:16.576: I/System.out(5340): waiting for debugger to settle...
08-19 12:42:16.779: I/System.out(5340): waiting for debugger to settle...
08-19 12:42:16.982: I/System.out(5340): waiting for debugger to settle...
08-19 12:42:17.186: I/System.out(5340): waiting for debugger to settle...
08-19 12:42:17.381: I/System.out(5340): waiting for debugger to settle...
08-19 12:42:17.584: I/System.out(5340): waiting for debugger to settle...
08-19 12:42:17.779: I/System.out(5340): waiting for debugger to settle...
08-19 12:42:17.982: I/System.out(5340): waiting for debugger to settle...
08-19 12:42:18.186: I/System.out(5340): waiting for debugger to settle...
08-19 12:42:18.381: I/System.out(5340): waiting for debugger to settle...
08-19 12:42:18.584: I/System.out(5340): waiting for debugger to settle...
08-19 12:42:18.787: I/System.out(5340): debugger has settled (1432)
08-19 12:42:19.037: D/libEGL(5340): loaded /system/lib/egl/libGLES_android.so
08-19 12:42:19.045: D/libEGL(5340): loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
08-19 12:42:19.053: D/libEGL(5340): loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
08-19 12:42:19.053: D/libEGL(5340): loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
08-19 12:42:19.162: D/OpenGLRenderer(5340): Enabling debug mode 0
08-19 12:42:33.834: D/AndroidRuntime(5340): Shutting down VM
08-19 12:42:33.834: W/dalvikvm(5340): threadid=1: thread exiting with uncaught exception (group=0x40ab6210)
08-19 12:42:33.889: E/AndroidRuntime(5340): FATAL EXCEPTION: main
08-19 12:42:33.889: E/AndroidRuntime(5340): java.lang.IllegalStateException: Could not execute method of the activity
08-19 12:42:33.889: E/AndroidRuntime(5340):     at android.view.View$1.onClick(View.java:3046)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at android.view.View.performClick(View.java:3526)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at android.view.View$PerformClick.run(View.java:14133)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at android.os.Handler.handleCallback(Handler.java:605)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at android.os.Handler.dispatchMessage(Handler.java:92)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at android.os.Looper.loop(Looper.java:137)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at android.app.ActivityThread.main(ActivityThread.java:4697)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at java.lang.reflect.Method.invokeNative(Native Method)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at java.lang.reflect.Method.invoke(Method.java:511)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at dalvik.system.NativeStart.main(Native Method)
08-19 12:42:33.889: E/AndroidRuntime(5340): Caused by: java.lang.reflect.InvocationTargetException
08-19 12:42:33.889: E/AndroidRuntime(5340):     at java.lang.reflect.Method.invokeNative(Native Method)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at java.lang.reflect.Method.invoke(Method.java:511)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at android.view.View$1.onClick(View.java:3041)
08-19 12:42:33.889: E/AndroidRuntime(5340):     ... 11 more
08-19 12:42:33.889: E/AndroidRuntime(5340): Caused by: android.os.NetworkOnMainThreadException
08-19 12:42:33.889: E/AndroidRuntime(5340):     at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1119)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at java.net.InetAddress.lookupHostByName(InetAddress.java:441)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at java.net.InetAddress.getAllByNameImpl(InetAddress.java:243)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at java.net.InetAddress.getAllByName(InetAddress.java:220)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at com.example.equinetravels.MainActivity.postData(MainActivity.java:79)
08-19 12:42:33.889: E/AndroidRuntime(5340):     at com.example.equinetravels.MainActivity.sendLogon(MainActivity.java:47)
08-19 12:42:33.889: E/AndroidRuntime(5340):     ... 14 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-09T22:56:23+00:00Added an answer on June 9, 2026 at 10:56 pm

    Looks like you’re getting a NetworkOnMainThreadException

    Try running it on a different thread?

    From the Javadocs:

    “The exception that is thrown when an application attempts to perform a networking operation on its main thread.

    This is only thrown for applications targeting the Honeycomb SDK or higher. Applications targeting earlier SDK versions are allowed to do networking on their main event loop threads, but it’s heavily discouraged. See the document Designing for Responsiveness. “

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to have my application read through a text file and look for
So I have been through most of the questions here. Also quite a few
I know there are several estimating questions here, and I have read through most
Have a look here: In the following code, what would be the type of
If you have a look here is the code below for future references. <h1>Accreditations</h1>
Lets say I have millions of packets to look through and I want to
I am trying to access a database through a simple PHP code. But the
I have had a look all over, but it doesn't seem as though my
I have look-up-table as defined below and I'm making use of GCC. When I
I often see a pattern used in circumstances where we have look-up code that

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.