Android GPS location problems -


i have problem setting current location gps. works should(notification finding location, set properly) on android 5.0.1(xiaomi redmi note 3) example on android 6.0 (sony xperia z5 compact) doesn't work @ all. no notification, gps position set never. on xperia don't have button on right of map showed line in code(mmap.setmylocationenabled(true);)

on android 4.4.2(gigabyte gsmart roma r2plus) no notification comes up, can see button of current location on right on top of screen. still doesn't work should.

@override public void onmapready(googlemap googlemap) {     mmap = googlemap;      if (activitycompat.checkselfpermission(this, android.manifest.permission.access_fine_location) != packagemanager.permission_granted && activitycompat.checkselfpermission(this, android.manifest.permission.access_coarse_location) != packagemanager.permission_granted) {         // todo: consider calling         //    activitycompat#requestpermissions         // here request missing permissions, , overriding         //   public void onrequestpermissionsresult(int requestcode, string[] permissions,         //                                          int[] grantresults)         // handle case user grants permission. see documentation         // activitycompat#requestpermissions more details.         return;     }      mmap.setmylocationenabled(true);     mmap.setmaptype(googlemap.map_type_normal);      locationmanager locationmanager = (locationmanager) getsystemservice(context.location_service);     criteria criteria = new criteria();     string provider = locationmanager.getbestprovider(criteria, false);      location location = locationmanager.getlastknownlocation(provider);     if (location != null) {         latitude = location.getlatitude();         longitude = location.getlongitude();     } else {      }      final firebaseuser user = firebaseauth.getinstance().getcurrentuser();     emailicek = user.getemail();     emailicek = emailicek.replace(".", "");     mdatabase = firebasedatabase.getinstance().getreference();      if (latitude != 0) {         if (longitude != 0) {             mdatabase.child("userdata/" + email + "/latitude").setvalue(latitude);             mdatabase.child("userdata/" + email + "/longitude").setvalue(longitude);         }     }     latlng latlng = new latlng(latitude, longitude);     mmap.movecamera(cameraupdatefactory.newlatlng(latlng));     //mmap.animatecamera(cameraupdatefactory.zoomto(14));      if (latitude != 0) {         mmap.animatecamera(cameraupdatefactory.zoomto(14));     } else {         mmap.animatecamera(cameraupdatefactory.zoomto(1));     } } 

did make sure requested right permissions in manifest? last known location you'll need

<uses-permission android:name="android.permission.access_coarse_location"/> 

for network based location, or:

<uses-permission android:name="android.permission.access_fine_location" /> 

for gps based location.

by way there lot of reasons why should consider moving play services location, suggest read this:

getting last known location - android developers


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -