Unable to override locationListener class methods

I want to get the current location using GPS.

Here is my script. My class definition:

public class UseGps extends Activity implements LocationListener

If Í try to override LocationListener methods like this

1)

@Override 
public void onLocationChanged(Location loc)

2)

@Override
public void onProviderDisabled(String provider)

3)

@Override
public void onProviderEnabled(String provider)

he gives me a compilation error saying

The method onStatusChanged(String, int, Bundle) of type UseGps must override a superclass method remove override.

The same for 2) and 3)

What is wrong here?

+3
source share
2 answers

Assuming you are using Eclipse, follow these steps to make sure your compliance level is 1.6.

Go to ProjectPropertiesJava Compiler. Make sure the parameter is Compiler compliance levelset to 1.6.

, WindowPreferencesJavaCompiler. 1.6 Compiler compliance level.

+11

- , , :

  • @Override Java 1.6.

  • Java 1.5 @Override , , - . Java 1.5 @Override , .

  • Java 1.6, @Override, , ( , , @Implements).

  • Eclipse , , Java, Java, , - Compiler Compliance Level. 1.5, JDK 1.6, , Java 1.5.

+4

Source: https://habr.com/ru/post/1789683/


All Articles