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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:28:44+00:00 2026-05-21T07:28:44+00:00

We needed a location service for our app that was available from anyplace. We

  • 0

We needed a location service for our app that was available from anyplace.
We used s singletone with Application context for system services and more, and has two basic methods start and stop which listen to location providers and stop listening respectively.

We have getLastLocation method that retrieves the current most updated and accurate location we could find.

We have another method that gives me a headache 🙂

Location getLocationWithWait(Class c) which supposed to get a location if available, if not it will return null and will create a Timer for 45 seconds.if the 45 seconds have passed and no location was found then the timer will broadcast to the class given in the parameter a ‘no location’ broadcast, otherwise if the location callbacks will be called they will cancel the timer and will send ‘location found’ broadcast to the class in the parameter.
So here are my questions:

  1. i started to think the whole
    architecture here is wrong, any
    better way to implement a location
    service to cater ANY Activity in my
    application ?
  2. i used a Timer an not Handler since
    the singletone i use is NOT an
    activity so i have no Looper an
    creating a thread with looper looks
    to me just as bad as creating
    another Thread for the timer… i
    did wanted to use the Activity
    instead, but then… if the activity
    pauses and resumes i need to keep
    track of the timer’s remaining time.
  3. the broadcasts may also be of a
    problem since if the activty pauses
    it will miss the broadcast and then
    i need to keep track in my
    singletone after several states,
    StickyBroadcast may solve it but
    that one i can’t send to specific
    class but to the whole system only.

So finally will it be any advantage to make this class a Service ?(to be honest i thought of maybe one advantage but not much) i want a location service with timeout much like google do in their “My Location” in maps.

10x.

  • 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-21T07:28:44+00:00Added an answer on May 21, 2026 at 7:28 am

    Wouldn’t it be better to use a LocationListener, as described in Requesting Location Updates?

    You can then use a ‘FastFix’ in onResume()

    Without knowing a bit more about your requirements, it’s difficult to make more specific suggestions.

    Hope this helps,

    Phil Lello

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

Sidebar

Related Questions

I needed to update the system tray icon's text value, of my application, whenever
I'm working on some application that should fetch current location and after device is
I needed to create some PDF document , that can set background color of
We needed to monitor all processes Registry calls/File Sytem calls/Process creations in the system
I needed to find all the files that contained a specific string pattern. The
I needed a generic collection or list that can fire an event when an
I needed to convert a Java 1.5se app to C# 2.0. Does anyone know
I am writing an compass application but can't access the sensors needed for some
I need to daily run a script that will download a file from a
I've been giving a application to work on that uses a Java EE application

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.