1
我想在應用程序中獲取用戶的當前位置。每次我用LocationManager
得到這個錯誤:LocationManager Android 4.4.1的問題
The method requestLocationUpdates(String, long, float, LocationListener) in the type LocationManager is not applicable for the arguments (String, int, int, MainActivity).
這是我的代碼:
public class MainActivity extends ActionBarActivity implements LocationListener
{
private GoogleMap googleMap;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
//I get error in this line
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
}
@Override
protected void onResume()
{
super.onResume();
}
@Override
public void onLocationChanged(Location location)
{
// TODO Auto-generated method stub
double latitude = (double) (location.getLatitude());
double longitude = (double) (location.getLongitude());
Log.i("Geo_Location", "Latitude: " + latitude + ", Longitude: " + longitude);
}
}
而且LocationListener的實現拋出了我的錯誤,而且必須這樣android.location.LocationListener
任何幫助來實現我會真的很感激。
PD:我使用Eclipse