• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

GPS not identified by the locationmanager

 
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wrote a program to identify the location details.Below is the Main class




below is the manifest file




but when i run this in my phone it gives me "Location not available" for every time.I debug the code and check .Then the provider is gps.I have already activated the gps in my phone.
If i remove the "ACCESS_FINE_LOCATION" from manifest file it runs the as expected .why it doesn't run with gps ?
Also when the location changes the values are not changing?
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are using wrong code to request location updates. You need to use LocationManager.GPS_PROVIDER.
Correct Code snippet for accessing location from GPS

Complete code for onCreate() method of your activity. Refer complete android gps location manager tutorial.

What if GPS is not available?
You need to redirect user to location settings so that he can enable it. Use onProviderDisabled method to do so. Refer below code:

The above snippet helps to redirect user to location settings page via intent.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic