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

  • Home
  • SEARCH
  • 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 9157977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:08:42+00:00 2026-06-17T13:08:42+00:00

I am using the Criteria object to get the best provider like so final

  • 0

I am using the Criteria object to get the best provider like so

final boolean isGpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
if(isGpsEnabled) {
      Criteria crit = new Criteria();
      crit.setAccuracy(Criteria.ACCURACY_FINE);
      crit.setCostAllowed(true);
      crit.setPowerRequirement(Criteria.NO_REQUIREMENT);
      crit.setSpeedRequirement(false);
      String provider = locationManager.getBestProvider(criteria, true);
      locationManager.requestLocationUpdates(provider, 600000, 0, new myLocationListener());
}

On my phone (Android 4.1) I have both “Use GPS Satellites” and “Use Wireless Networks” options enabled. Now, the above code works great when I am outdoors and it gives me the GPS location.

But, when I am indoors it does not revert to the “network” provider. It just keeps trying to get the location via GPS and never get its (I wait 1 minute or so)

When I change the code of Criteria to use Criteria.ACCURACY_COARSE then it uses “network” provider.

How do I get it to first try the GPS (because it is enabled) and because we are indoor it will not be able to connect to a satellite to then fall back to using the “network”. I can’t get that working easily. I state again, GPS is enabled but no access to satellites so want it to get network location instead.

Thanks.

  • 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-17T13:08:43+00:00Added an answer on June 17, 2026 at 1:08 pm

    The solution was create the location manager and attach 2 listeners to receive updates. One for GPS and another for NETWORK. You set it to receive updates fairly quickly (or depending on your own case, I just needed to get the location) You then create a method that compares the location of the GPS and Network and find which one is more accurate. You do this at most 3 times to get on average which one is returning the most accurate position and then you stop the location updates.

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

Sidebar

Related Questions

Iam using locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); Criteria criteria = new Criteria(); String bestProvider =
how can we get distinct result by using criteria in hibernate.
How can i get the current view criteria using php and the mysql statement
I've been using my own object cache which works more or less: get objet
I have mocked an object using Easymock.createNiceMock . MYRepository mockedMyRepository = EasyMock.createNiceMock(MyRepositoryWrapper.class); EasyMock.expect(mockedRepository.findList(Asset.class, criteria)).andReturn(statusTypeList);
I want fetch last record using hibernate criteria Can u help me?
I'm trying to filter by a list of values using the criteria API. I
How would I go about executing the following Hibernate query using the criteria API.
I'm trying to make a MATCH of columns using multiple criteria, as in the
when using document's id as the only criteria in my query what's the difference

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.