我正在尝试使用locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
但我得到一个错误说:
我认为它可能来自错误的LocationListerner
库,但这里是我导入的所有库
import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationManager;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.widget.Toast;
import com.example.ahmed.mob_review.MainActivity;
import com.example.ahmed.mob_review.R;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
EDITED
答案 0 :(得分:1)
试试这个......
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,0, (LocationListener) this);
答案 1 :(得分:1)
解决了:
LocationListener
this
个活动投放到LocationListener
onLocationChanged
和NETWORK_PROVIDER
之前,我不会调用GPS_PROVIDER
<强>如:强>
locationManager.requestLocationUpdates(locationManager.GPS_PROVIDER, 0, 0, (LocationListener) this);
locationManager.requestLocationUpdates(locationManager.NETWORK_PROVIDER, 0, 0, (LocationListener) this);
现在它起作用了:)