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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:20:08+00:00 2026-06-13T09:20:08+00:00

I’m getting the following error: 10-24 13:31:14.252: E/AndroidRuntime(21983): FATAL EXCEPTION: main 10-24 13:31:14.252: E/AndroidRuntime(21983):

  • 0

I’m getting the following error:

10-24 13:31:14.252: E/AndroidRuntime(21983): FATAL EXCEPTION: main
10-24 13:31:14.252: E/AndroidRuntime(21983): java.lang.RuntimeException: Unable to start activity ComponentInfo{br.com.campusfqm.cfqm/br.com.campusfqm.cfqm.Launch}: android.os.NetworkOnMainThreadException
10-24 13:31:14.252: E/AndroidRuntime(21983):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1968)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1993)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at android.app.ActivityThread.access$600(ActivityThread.java:127)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1159)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at android.os.Handler.dispatchMessage(Handler.java:99)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at android.os.Looper.loop(Looper.java:137)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at android.app.ActivityThread.main(ActivityThread.java:4507)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at java.lang.reflect.Method.invokeNative(Native Method)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at java.lang.reflect.Method.invoke(Method.java:511)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at dalvik.system.NativeStart.main(Native Method)
10-24 13:31:14.252: E/AndroidRuntime(21983): Caused by: android.os.NetworkOnMainThreadException
10-24 13:31:14.252: E/AndroidRuntime(21983):    at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at java.net.InetAddress.lookupHostByName(InetAddress.java:391)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at java.net.InetAddress.getAllByName(InetAddress.java:220)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at libcore.net.http.HttpConnection.<init>(HttpConnection.java:71)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:351)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at libcore.net.http.HttpEngine.connect(HttpEngine.java:303)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at br.com.campusfqm.cfqm.Launch.onCreate(Launch.java:54)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at android.app.Activity.performCreate(Activity.java:4465)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
10-24 13:31:14.252: E/AndroidRuntime(21983):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1932)
10-24 13:31:14.252: E/AndroidRuntime(21983):    ... 11 more

Pointing to

urlConnection.connect();

This is the full code

            URL url = new URL("http://www.google.com/");

        //create the new connection
        HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();

        //set up some things on the connection
        urlConnection.setRequestMethod("GET");
        urlConnection.setDoOutput(true);

        //and connect!
        urlConnection.connect();

        //set the path where we want to save the file
        //in this case, going to save it on the root directory of the
        //sd card.
        File SDCardRoot = Environment.getExternalStorageDirectory();
        //create a new file, specifying the path, and the filename
        //which we want to save the file as.
        File file = new File(SDCardRoot,fileName);

        //this will be used to write the downloaded data into the file we created
        FileOutputStream fileOutput = new FileOutputStream(file);

        //this will be used in reading the data from the internet
        InputStream inputStream = urlConnection.getInputStream();

        //this is the total size of the file
        int totalSize = urlConnection.getContentLength();
        //variable to store total downloaded bytes
        int downloadedSize = 0;

        //create a buffer...
        byte[] buffer = new byte[1024];
        int bufferLength = 0; //used to store a temporary size of the buffer

        //now, read through the input buffer and write the contents to the file
        while ( (bufferLength = inputStream.read(buffer)) > 0 ) {
                //add the data in the buffer to the file in the file output stream (the file on the sd card
                fileOutput.write(buffer, 0, bufferLength);
                //add up the size so we know how much is downloaded
                downloadedSize += bufferLength;
                //this is where you would do something to report the prgress, like this maybe
                Log.v("cfqm",""+downloadedSize+"/"+totalSize);

        }
        //close the output stream when done
        fileOutput.close();
  • 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-13T09:20:09+00:00Added an answer on June 13, 2026 at 9:20 am

    It is android.os.NetworkOnMainThreadException Means you are doing network connections on main thread. Use AsyncTask or thread to perform network operations instead of UI thread

    Read here about AsyncTask

    Example

    Similar problem

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Specifically, suppose I start with the string string =hello \'i am \' me And
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have thousands of HTML files to process using Groovy/Java and I need to
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.