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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:50:31+00:00 2026-06-01T12:50:31+00:00

I have an app which was tested thoroughly and working fine on Android Gingerbread

  • 0

I have an app which was tested thoroughly and working fine on Android Gingerbread (and older Android versions). I’ve noticed from users’ reported crash errors that phones running later versions of the Android operating system are throwing a NetworkOnMainThreadException.

I’m trying to work through my code and eliminate/fix all culprits. Would the GeoCoder getFromLocation and getFromLocationName methods throw a NetworkOnMainThreadException if called from the main/ui thread?

  • 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-01T12:50:33+00:00Added an answer on June 1, 2026 at 12:50 pm

    Seems like these Geocoder methods and any networking or i/o calls are going to throw up a NetworkOnMainThreadException. So, if in doubt, stick it in a separate thread!

    Here’s an example of how to call the GeoCoder.getFromLocation() method from another thread:

    new AsyncTask<GeoPoint, Void, Address>()
    {
      @Override
      protected Address doInBackground(GeoPoint... geoPoints)
      {
        try
        {
          Geocoder geoCoder = new Geocoder(context);
          double latitude = geoPoints[0].getLatitudeE6() / 1E6;
          double longitude = geoPoints[0].getLongitudeE6() / 1E6;
          List<Address> addresses = geoCoder.getFromLocation(latitude, longitude, 1);
          if (addresses.size() > 0)
            return addresses.get(0);
        }
        catch (IOException ex)
        {
          // log exception or do whatever you want to do with it!
        }
        return null;
      }
    
      @Override
      protected void onPostExecute(Address address)
      {
        // do whatever you want/need to do with the address found
        // remember to check first that it's not null
      }
    }.execute(myGeoPoint);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on the in app billing in android and I have tested
I have an app which could benefit from the user being able to choose
I've tested my app thoroughly on the simulator, but I don't have an iphone/ipad/ipod
I have an app on the android market, which uses the mapview to display
I'm starting an Android app which will have multiple Activities. It will be using
I have an app which allows users to log in via Facebook, and all
I work on a high-profile app which runs on all versions of Android. Unfortunately
I have an Android app which by preference uses external storage if available to
I have an Android app (2.1 to 2.3) that successfully receives locations from the
I have an App for a client which is externally tested by another company

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.