Estoy trabajando con google map donde mi app me debe montrar mi ubicación actual , la app funciona perfectamente, me muestra la ubicación actual , pero solo en teléfono Samsung , intente correrla en Motorola , solo me figura la mapa , pero no la ubicación indicada.. ahí esta mi código lo que intente de hacer...
private GoogleMap mMap;
private static final float ZOOM = 15f;
private static final int LOCATION_PERMISSION_REQUEST_CODE = 2345;
private Boolean mLocationPermissions = false;
private FusedLocationProviderClient mFusedLocationProviderClient;
onCreate(){
/*....
*/
initializarMap();
}
private void initializarMap() {
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync((OnMapReadyCallback) this);
}
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
if (mLocationPermissions) {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
mMap.setMyLocationEnabled(true);
}
}
private void getDeviceLocation(){
Log.d("MapsActivity.this", "getDeviceLocation: getting the devices current location");
mFusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this);
try{
if(mLocationPermissionsGranted){
final Task location = mFusedLocationProviderClient.getLastLocation();
location.addOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(@NonNull Task task) {
if(task.isSuccessful()){
Log.d("MapsActivity.this", "onComplete: found location!");
Location currentLocation = (Location) task.getResult();
mCamera(new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude()),
ZOOM,"My location");
}else{
Log.d("MapsActivity.this", "onComplete: current location is null");
Toast.makeText(MainActivity.this, "unable to get current location", Toast.LENGTH_SHORT).show();
}
}
});
}
}catch (SecurityException e){
Log.e("MapsActivity.this", "getDeviceLocation: SecurityException: " + e.getMessage() );
}
}
private void mCamera(LatLng latLng, float zoom,String title){
Log.d("MapsActivity.this", "mCamera: moving the camera to: lat: " + latLng.latitude + ", lng: " + latLng.longitude );
mMap.mCamera(CameraUpdateFactory.newLatLngZoom(latLng, zoom));
MarkerOptions options= new MarkerOptions().position(latLng).title(title);
mMap.addMarker(options);
}
los celulares samsung en los cuales funciona la app tienen api , 22 y 23 y el motorola tiene api 27 no se si me falta algun permiso o existe un permiso especial para motorola
los samsung tienen, 22 lollipop y 23 marshmollow y el motorola tiene 27 Oreo