Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GPS not identified by the locationmanager

 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • 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?
 
rajat ghai
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic