I'm trying to call the requestLocationUpdates method but eclipse says that the arguments are wrong.
The Main activity is set as :
public class MainActivity extends Activity implements LocationListener{... }
and the code with errors is :
final LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
trackLocation.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
boolean tracking = false;
if (!tracking){
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
} else {
// something
}
}
});
The locationManager.... line works fine outside the onClickListener.
What should be the right parameter to fix?
Thanks in advance
Replace "this" with "MainActivity.this".
If you just have "this", you are passing in the OnClickListener instead of the Activity.