Google api - Android location - no matter how I implement it I never get the location marker icon in the notification bar

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

I am trying to implement location in an Android application. I first tried the approach that I have learned from paid courses - extending the LocationListener. I tried working with the "best provider" returned by locationManager.getBestProvider, but I found out that it is too often GPS, which returns 0,0. So I changed everything to using 3 providers: gps, network and passive. Am displaying all latLng and accuracy from all 3. It is often the same, though the GPS returns 30% of the time 0,0.

Than I changed the whole approach to using GoogleApiClient. Implemented GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener and LocationListener.

The values here are somewhat similar to what I get with the first approach.

But no matter what I do, I never get the location marker icon in the notification bar. Like for google maps or any call-a-taxi app. Why is this?

Also, in both cases the apps appear in the "Recent location requests" in settings; the application name for LocationListener, and the Google App/Google Location History for the second approach.

I am testing on Nexus 4 (with stock 5.1.1) and 5 (stock 6.0.1) devices. Permissions are in the manifest, and added the necessary permission check for API level 23.

the Mainactivity classes can be found here: http://cristianbell.com/tmp/MainActivity_gapi.java http://cristianbell.com/tmp/MainActivity_gapi.java http://cristianbell.com/tmp/MainActivity_locListener.java http://cristianbell.com/tmp/MainActivity_locListener.java Thanks for all the help!

Answers

The location marker notification icon appear only if you use the LocationManager.GPS_PROVIDER on the method

lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 1, this);

if you use LocationManager.NETWORK_PROVIDER there no will be a icon in the status bar

  EDIT :   

Check aswell your location mode in Settings->Location->Mode set it to high

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/36621638/android-location-no-matter-how-i-implement-it-i-never-get-the-location-marker

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils