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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:09:56+00:00 2026-05-20T14:09:56+00:00

I have an android app that connects to the internet to do a reverse

  • 0

I have an android app that connects to the internet to do a reverse geocode on lat and long co-ordinates in real time. This lags the UI and can cause it to give a “not responding – force close/wait” error(as expected without using async/ threads-handlers!)

I have implemented an Async Task which works very well(no more UI lag!), but variables set inside the onLocationChanged method (that sets them to the latitude & longitude) are inaccessible.
The class I am doing this in, is linked to another seperate class that passes the variables and can send an sms to a person which includes the reverse-geocoded address.
However, since implementing the Async Task using the doinbackground method, I can no longer send what I need. I don’t know if I can explain any better, I will provide sample code.

public void onLocationChanged(Location loc){
    mylat = loc.getLatitude();
    mylong = loc.getLongitude();
}

/*
afaik, this is the code that does the internet stuff, that lags the 
UI.  If I put this in doinbackground, it cannot access mylat & my long, 
and the "loc.getLatitude" has to be done in the "onLocationChanged" 
method, which HAS to exist. If I leave the ListAddress code outside the 
doinbackground, everything works, BUT the UI will obviously lag.
*/
List<Address> addresses = geoCoder.getFromLocation(mylat,mylong, 1); 

Can anyone advise the best way to get mylat = loc.getLatitude(); & mylat = loc.getLatitude(); inside the doinbackground 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-20T14:09:56+00:00Added an answer on May 20, 2026 at 2:09 pm
    1. Override the constructor of your AsyncTask and set mylat and mylong as variables in that class
    2. or pass them to the doInBackground method directly.

      ... extends AsyncTask<Double, ProgressType, ReturnType> {
          protected ReturnType doInBackground(Double... params) {
              mylat = params[0];
              mylong = params[1];
              List addresses = geoCoder.getFromLocation(mylat, mylong, 1);
              ...
          }
          ...
      }
      

      and call it with execute(mylat, mylong);

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

Sidebar

Related Questions

I am developing an Android app, it will connect to the internet to load
I am building an app for Android 2.1 that provides notifications based on calendar
I have android code that uses a background process to routinely (e.g. hourly) connect
I have two threads in an Android application, one is the view thread, and
I'm doing some Android development, and I much prefer Visual Studio, but I'll have
Have you managed to get Aptana Studio debugging to work? I tried following this,
I am developing an Android app which needs to poll a specific webpage in
I have a Spring Security (form based authentication) web app running CXF JAX-RS webservices
I'm using eclipse, and I have two android projects which have different topics. And
I am using android G1 phone and now I have upgraded my SDK to

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.