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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:58:32+00:00 2026-05-24T04:58:32+00:00

I’m trying to load a remote file and I have to use HttpClient.execute which

  • 0

I’m trying to load a remote file and I have to use HttpClient.execute which always throws an error. Any ideas?

Function I’m using:

private void loadCol3(Map.Entry<String, String> map) {
    LinearLayout col3 = (LinearLayout)findViewById(R.id.col3);
    String result = null;
    col3.removeAllViews();

    Log.d(TAG, "start load col 3");

    HttpClient httpclient = new DefaultHttpClient();
    HttpGet request = new HttpGet("http://video.foxbusiness.com/v/feed/playlist/"+map.getValue()+".js?template=fox&callback=?");
    ResponseHandler<String> handler = new BasicResponseHandler();  

    try {  
        result = httpclient.execute(request, handler);  
    } catch (Exception e) {
        Log.d(TAG, "httpclient.execute failed");
        e.printStackTrace();  
    }
    httpclient.getConnectionManager().shutdown();

    try {
        JSONObject completeJSONObj = new JSONObject(result);
        String json = completeJSONObj.toString();
        Log.d(TAG, json);
        JSONObject results = completeJSONObj.getJSONObject("results");
    } catch (JSONException e) {
        Log.d(TAG,"JSON parsing error:" + e.getMessage());
    }
}

manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.tv"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="11" />
    <uses-permission android:name="android.permission.INTERNET" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">

        <activity android:name=".MyActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
</manifest>

Current log when ran:

07-31 17:56:17.175: DEBUG/log_tag(10869): start load col 3
07-31 17:56:17.205: DEBUG/log_tag(10869): httpclient.execute failed

Last line of console:

[2011-07-31 11:57:57 - My app] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.tv/.MyActivity }

** edit – stacktraces **

07-31 18:11:47.475: WARN/System.err(11083): android.os.NetworkOnMainThreadException
07-31 18:11:47.475: WARN/System.err(11083):     at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1077)
07-31 18:11:47.475: WARN/System.err(11083):     at java.net.InetAddress.lookupHostByName(InetAddress.java:477)
07-31 18:11:47.475: WARN/System.err(11083):     at java.net.InetAddress.getAllByNameImpl(InetAddress.java:277)
07-31 18:11:47.475: WARN/System.err(11083):     at java.net.InetAddress.getAllByName(InetAddress.java:249)
07-31 18:11:47.475: WARN/System.err(11083):     at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:136)
07-31 18:11:47.475: WARN/System.err(11083):     at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
07-31 18:11:47.475: WARN/System.err(11083):     at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
07-31 18:11:47.475: WARN/System.err(11083):     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
07-31 18:11:47.475: WARN/System.err(11083):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
07-31 18:11:47.475: WARN/System.err(11083):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:653)
07-31 18:11:47.475: WARN/System.err(11083):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:627)
07-31 18:11:47.475: WARN/System.err(11083):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:616)
07-31 18:11:47.475: WARN/System.err(11083):     at com.foxbusiness.tv.FOXBusinessActivity.loadCol3(FOXBusinessActivity.java:134)
07-31 18:11:47.475: WARN/System.err(11083):     at com.foxbusiness.tv.FOXBusinessActivity.access$1(FOXBusinessActivity.java:121)
07-31 18:11:47.475: WARN/System.err(11083):     at com.foxbusiness.tv.FOXBusinessActivity$2.onClick(FOXBusinessActivity.java:113)
07-31 18:11:47.475: WARN/System.err(11083):     at android.view.View.performClick(View.java:3110)
07-31 18:11:47.475: WARN/System.err(11083):     at android.view.View$PerformClick.run(View.java:11928)
07-31 18:11:47.485: WARN/System.err(11083):     at android.os.Handler.handleCallback(Handler.java:587)
07-31 18:11:47.485: WARN/System.err(11083):     at android.os.Handler.dispatchMessage(Handler.java:92)
07-31 18:11:47.485: WARN/System.err(11083):     at android.os.Looper.loop(Looper.java:132)
07-31 18:11:47.485: WARN/System.err(11083):     at android.app.ActivityThread.main(ActivityThread.java:4025)
07-31 18:11:47.485: WARN/System.err(11083):     at java.lang.reflect.Method.invokeNative(Native Method)
07-31 18:11:47.485: WARN/System.err(11083):     at java.lang.reflect.Method.invoke(Method.java:491)
07-31 18:11:47.485: WARN/System.err(11083):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
07-31 18:11:47.485: WARN/System.err(11083):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
07-31 18:11:47.485: WARN/System.err(11083):     at dalvik.system.NativeStart.main(Native Method)

07-31 18:09:26.915: ERROR/AndroidRuntime(11024): FATAL EXCEPTION: main
07-31 18:09:26.915: ERROR/AndroidRuntime(11024): java.lang.NullPointerException
07-31 18:09:26.915: ERROR/AndroidRuntime(11024):     at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:112)
07-31 18:09:26.915: ERROR/AndroidRuntime(11024):     at org.json.JSONTokener.nextValue(JSONTokener.java:90)
07-31 18:09:26.915: ERROR/AndroidRuntime(11024):     at org.json.JSONObject.<init>(JSONObject.java:154)
07-31 18:09:26.915: ERROR/AndroidRuntime(11024):     at org.json.JSONObject.<init>(JSONObject.java:171)
07-31 18:09:26.915: ERROR/AndroidRuntime(11024):     at com.example.tv.MyActivity.loadCol3(MyActivity.java:142)
07-31 18:09:26.915: ERROR/AndroidRuntime(11024):     at com.example.tv.MyActivity.access$1(MyActivity.java:121)
07-31 18:09:26.915: ERROR/AndroidRuntime(11024):     at com.example.tv.MyActivity$2.onClick(MyActivity.java:113)
07-31 18:09:26.915: ERROR/AndroidRuntime(11024):     at android.view.View.performClick(View.java:3110)
07-31 18:09:26.915: ERROR/AndroidRuntime(11024):     at android.view.View$PerformClick.run(View.java:11928)
07-31 18:09:26.915: ERROR/AndroidRuntime(11024):     at android.os.Handler.handleCallback(Handler.java:587)
07-31 18:09:26.915: ERROR/AndroidRuntime(11024):     at android.os.Handler.dispatchMessage(Handler.java:92)
07-31 18:09:26.915: ERROR/AndroidRuntime(11024):     at android.os.Looper.loop(Looper.java:132)
07-31 18:09:26.915: ERROR/AndroidRuntime(11024):     at android.app.ActivityThread.main(ActivityThread.java:4025)
07-31 18:09:26.915: ERROR/AndroidRuntime(11024):     at java.lang.reflect.Method.invokeNative(Native Method)
07-31 18:09:26.915: ERROR/AndroidRuntime(11024):     at java.lang.reflect.Method.invoke(Method.java:491)
07-31 18:09:26.915: ERROR/AndroidRuntime(11024):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
07-31 18:09:26.915: ERROR/AndroidRuntime(11024):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
07-31 18:09:26.915: ERROR/AndroidRuntime(11024):     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-24T04:58:33+00:00Added an answer on May 24, 2026 at 4:58 am

    You get the NullpointerException because you access the result even when the GET method fails.

    As for the NetworkOnMainThreadException, well the problem is exactly that: You do networking on the main thread. Run your GET request in either an AsyncTask or an IntentService.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have just tried to save a simple *.rtf file with some websites and
I want use html5's new tag to play a wav file (currently only supported
I have a text area in my form which accepts all possible characters from
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a reasonable size flat file database of text documents mostly saved in
I am trying to loop through a bunch of documents I have to put
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small

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.