我用三部手机测试了这段代码。它适用于其中两个,但不适用于第三个Huawei y9 2019。有什么问题?, 为什么会显示 (?) 和 (*) 符号?
我的代码是:
mFusedLocationProviderClient = new FusedLocationProviderClient(this);
mLocationRequest = LocationRequest.create();
mLocationRequest.setInterval(1000);
mLocationRequest.setFastestInterval(500);
mLocationRequest.setPriority(LocationRequest.PRIORITY_LOW_POWER);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
mFusedLocationProviderClient.requestLocationUpdates(
mLocationRequest,
new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
if(locationResult != null){
Log.i("Your_Location",locationResult.getLastLocation().toString()+"\n\nrequestLocationUpdates() isCall");
textView.setText(locationResult.getLastLocation().toString());
}
else{
Log.i("Your_Location"," requestLocationUpdates() isCall Please Give Permission and On Location");
textView.setText("Please Give Permission and On Location");
}
super.onLocationResult(locationResult);
}
},
getMainLooper()
);