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 7554659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:23:50+00:00 2026-05-30T11:23:50+00:00

I’m using the following function to get a JSON Array from a php webpage.

  • 0

I’m using the following function to get a JSON Array from a php webpage.

While this exact code works on the 2.3 version of the app, on the 3.0 version that I’m currently building it force-closes and gives me a weird error log.

Any help would be great…

Are there any particularities to Honeycomb as opposed to Gingerbread when using http posts and things like that?

    private void getNews(){
    try{
    HttpGet httpGet = new HttpGet("http://www.ace.ucv.ro/android/stiri.php?perpage=20");

    result = EntityUtils.toString(new DefaultHttpClient().execute(httpGet).getEntity());

    JSONArray jsonMainArray = new JSONArray(result);


} catch (ParseException e) {
    e.printStackTrace();
} catch (ClientProtocolException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
} catch (JSONException e) {
    e.printStackTrace();
}
}   

And calling the function:

        getNews.setOnClickListener(new OnClickListener(){
        public void onClick(View view){
            getNews();
        }
    });

And the error log

02-26 16:06:42.218: W/dalvikvm(478): threadid=1: thread exiting with uncaught exception (group=0x40014760)
02-26 16:06:42.247: E/AndroidRuntime(478): FATAL EXCEPTION: main
02-26 16:06:42.247: E/AndroidRuntime(478): android.os.NetworkOnMainThreadException
02-26 16:06:42.247: E/AndroidRuntime(478):  at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1077)
02-26 16:06:42.247: E/AndroidRuntime(478):  at java.net.InetAddress.lookupHostByName(InetAddress.java:477)
02-26 16:06:42.247: E/AndroidRuntime(478):  at java.net.InetAddress.getAllByNameImpl(InetAddress.java:277)
02-26 16:06:42.247: E/AndroidRuntime(478):  at java.net.InetAddress.getAllByName(InetAddress.java:249)
02-26 16:06:42.247: E/AndroidRuntime(478):  at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:136)
02-26 16:06:42.247: E/AndroidRuntime(478):  at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
02-26 16:06:42.247: E/AndroidRuntime(478):  at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
02-26 16:06:42.247: E/AndroidRuntime(478):  at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
02-26 16:06:42.247: E/AndroidRuntime(478):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
02-26 16:06:42.247: E/AndroidRuntime(478):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
02-26 16:06:42.247: E/AndroidRuntime(478):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
02-26 16:06:42.247: E/AndroidRuntime(478):  at pirelli.app.ScanBarcode.getNews(ScanBarcode.java:46)
02-26 16:06:42.247: E/AndroidRuntime(478):  at pirelli.app.ScanBarcode.access$4(ScanBarcode.java:42)
02-26 16:06:42.247: E/AndroidRuntime(478):  at pirelli.app.ScanBarcode$5.onClick(ScanBarcode.java:164)
02-26 16:06:42.247: E/AndroidRuntime(478):  at android.view.View.performClick(View.java:3110)
02-26 16:06:42.247: E/AndroidRuntime(478):  at android.view.View$PerformClick.run(View.java:11934)
02-26 16:06:42.247: E/AndroidRuntime(478):  at android.os.Handler.handleCallback(Handler.java:587)
02-26 16:06:42.247: E/AndroidRuntime(478):  at android.os.Handler.dispatchMessage(Handler.java:92)
02-26 16:06:42.247: E/AndroidRuntime(478):  at android.os.Looper.loop(Looper.java:132)
02-26 16:06:42.247: E/AndroidRuntime(478):  at android.app.ActivityThread.main(ActivityThread.java:4123)
02-26 16:06:42.247: E/AndroidRuntime(478):  at java.lang.reflect.Method.invokeNative(Native Method)
02-26 16:06:42.247: E/AndroidRuntime(478):  at java.lang.reflect.Method.invoke(Method.java:491)
02-26 16:06:42.247: E/AndroidRuntime(478):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
02-26 16:06:42.247: E/AndroidRuntime(478):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
02-26 16:06:42.247: E/AndroidRuntime(478):  at dalvik.system.NativeStart.main(Native Method)
  • 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-05-30T11:23:52+00:00Added an answer on May 30, 2026 at 11:23 am

    If you looked for “NetworkOnMainThreadException” in El Goog, the first thing you get is the link to the Android docs. It states that this exception is since Api Level 11 (Honeycomb 3.0), that’s why you were not getting it before. It also even links to the “Designing for Responsiveness” page. The proper way to do network operations is, like some of the commenters suggested, via an AsyncTask.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.