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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:32:11+00:00 2026-05-22T11:32:11+00:00

Hey guys I am developing an application in which i need to find the

  • 0

Hey guys
I am developing an application in which i need to find the latitude
longitude of the user. I am able to find latitude longitude by network providers through following code :-

LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
loc = lm.getLastKnownLocation(lm.NETWORK_PROVIDER);
Toast.makeText(BaseScreen.this, "Lat: "+loc.getLatitude()+" long: "+loc.getLongitude(), Toast.LENGTH_LONG).show();

Now the following are the cases which i need to implement :-

  • What if user is in a building and he can not retrieve data from GPS
  • What if the user has GPS switched off and wants to get location from Network
  • My application has like 20 activities if i place the code of locationlistener in one base screen which is extended by other activities and keep saving the latitude and longitude in some datamanager then will the call back work in that base screen activity even if the activity is not the main UI activity??
  • 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-22T11:32:12+00:00Added an answer on May 22, 2026 at 11:32 am

    a. Usually we should register for both GPS and network provider while requesting updates, this takes care of the line-of-sight problem where we automatically fall back on network provided values.

    b. If the GPS is switched off you can check that from the code by using isProviderEnabled(), if not than your only option is to use the Network Provider.

    c. Better still have LocationListener as a separate class and in onLocationChanged store the location received which should be available across your application.

    To register use android.location.LocationListener.requestLocationUpdates

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

Sidebar

Related Questions

Hey guys i am new to android development, I am developing a project which
hey guys, I have mypage.com/user-login.php?action=register and I want to be able to call mypage.com/register
hey guys, i'm getting an exception on the following inner exception: {Value cannot be
Hey guys i wrote a quick test. I want delete to call deleteMe which
Hey guys, I have a little issue here. I need my users to be
Hey guys! I have this little problem: I have one ViewController which adds 2
Hey guys. I have a method that gets called each second which I want
hey guys here at stackoverflow.com I'm a student and developing a small todo app
Hey guys, I'm having some trouble with a screen from the app I'm developing.
Hey guys I am struggling to create a query which gives schedule of a

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.