Alex Teslin
Lurker
Hi,
I am trying to follow the chapter 33 of Programming Android book (edition 3). I cannot get the following method work. First, I am getting a compiler error with red squiggly line "Call requires permission which may be rejected by user..." But I've got the permission implementation done.
When I introduce the following if statement (by selecting from the list when Alt+Enter) the above red squiggly error goes away. But the onLocationChanged(Location location) method is never executed.
This line Log.i("findImage", "onLocationChanged"); never executes.
Any suggestions please?
I am trying to follow the chapter 33 of Programming Android book (edition 3). I cannot get the following method work. First, I am getting a compiler error with red squiggly line "Call requires permission which may be rejected by user..." But I've got the permission implementation done.
When I introduce the following if statement (by selecting from the list when Alt+Enter) the above red squiggly error goes away. But the onLocationChanged(Location location) method is never executed.
This line Log.i("findImage", "onLocationChanged"); never executes.
Java:
private void findImage(){
Log.i("findImage", "findImage - first line");
LocationRequest request = LocationRequest.create();
request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
request.setNumUpdates(1);
request.setInterval(0);
Log.i("findImage", "findImage - after request");
if(hasLocationPermission()){
Log.i("findImage", "findImage - if(hasLocationPermission())");
LocationServices.FusedLocationApi
.requestLocationUpdates(mClient, request, new LocationListener() {
})
try {
LocationServices.FusedLocationApi
.requestLocationUpdates(mClient, request, new LocationListener(){
@Override
public void onLocationChanged(Location location){
Log.i("findImage", "onLocationChanged");
}
});
} catch (Exception ex){
Log.i("findImage", "findImage - GeneralException" + ex.getMessage());
} finally {
Log.i("findImage", "findImage - Finally block");
}
}
Log.i("findImage", "findImage - last line");
}
Any suggestions please?
