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

The Archive Base Latest Questions

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

I am using android 2.3.3, i had made an rss reader which was working

  • 0

I am using android 2.3.3, i had made an rss reader which was working great, then i integrated the code of that simple rss reader into another activity, just copy pasted it carefully, no errors there.

The problem is when i run the app on my emulator it gives me error connecting exception. Then i figured out by putting toasts after everyline in try block that the problem is at httpconnection.connect(); line.

I have added the permission in the android manifest while my logcat gives a warning of javaio exception:error connecting.

    try {
        HttpURLConnection httpURLConnection = (HttpURLConnection) connection;
        //Toast.makeText(this, "urlconnection passed", Toast.LENGTH_SHORT).show();
        httpURLConnection.setAllowUserInteraction(false);
        httpURLConnection.setInstanceFollowRedirects(true);
        //Toast.makeText(this, "setting response method", Toast.LENGTH_SHORT).show();
        httpURLConnection.setRequestMethod("GET");
        //Toast.makeText(this, "connecting", Toast.LENGTH_SHORT).show();
        httpURLConnection.connect();
        Toast.makeText(this, "on response code", Toast.LENGTH_SHORT).show();
        response = httpURLConnection.getResponseCode();
        //Toast.makeText(this, "response code passed", Toast.LENGTH_SHORT).show();
        if (response == HttpURLConnection.HTTP_OK) {
            //Toast.makeText(this, "OK", Toast.LENGTH_SHORT).show();
            inputStream = httpURLConnection.getInputStream();
        }

    } catch (Exception e) {
        // TODO: handle exception
        throw new IOException("Error connecting");
    }

Here the code which creates the object:

URL url = new URL(UrlString);
URLConnection connection = url.openConnection();
if (!(connection instanceof HttpURLConnection)) 
  throw new IOException("Not a HTTP connection"); 
  • 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-09T15:56:24+00:00Added an answer on June 9, 2026 at 3:56 pm

    It gives networkonmainthread exception

    This means that you are doing network operations on the main thread, and that’s not allowed in the Strict Mode.

    “In the main thread” usually means that you are doing it in the event handlers, like onResume, onPause, or in the onClick method of your OnClickListener. You may look at this post (Painless threading) to understand what’s the problem and why this is not allowed. Generally, if you perform network operations in the main thread, it would block the processing of GUI events, and if the network operation was slow, your application would be not responsive.

    Strict Mode appeared in API level 9, so this explains that why you have problem if min SDK version is 10, and why it works with min SDK version 8.

    You should use AsyncTask or other methods to do it in the background. You may refer to 1 for this.

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

Sidebar

Related Questions

I was just wondering if Android had built in code so that I could
I'm working on an Android application that will send MMS internally without using the
I'm using the Android NDK to build a library. I had everything working well,
I've a Samsung Galaxy S2 device which I had been using for Android development
I'm working with android xml rpc to mount a server. For that I'm using
I am using android 2.1 platform.The code I have will display the Name number
I currently using android NDK to write some native code in C. I have
I am using Android SDK 1.6 and developing some simple apps. It seems everytime
Hi there Im new to mobile application development. I had developed Android apps using
I have a web app, that also has an iPhone and Android app using

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.