张家豪
张家豪

Reputation: 3

must either be declared abstract or implement abstract method

I get the following message when trying to implement a class:

enter image description here

public class MyLocationListener implements BDLocationListener

This sentence is wrong. The hint is:Class 'MyLocationListener' must either be declared abstract or implement abstract method 'onConnectHotSpotMessage(String, int)' in 'BDLocationListener

I use Android Studio.

Upvotes: 0

Views: 17549

Answers (2)

mVck
mVck

Reputation: 3030

Your BDLocationListener class has an Abstract method that needs to be implemented in your MyLocationlistener, it's like a contract, if a class wants to implement an abstract class it has to implement its abstract methods or to be abstract as well.

You can find more information about Abstract class here

Upvotes: 0

user681574
user681574

Reputation: 553

You are declaring that you're going to "implement BDLocationListener" which is an abstract class.

When you implement an abstract class, you must provide a method for every unimplemented abstract method within the abstract class. In this case, onConnectHotSpotMessage(String, int) is one of the abstract methods in that class.

You must either provide an implementation of this method in your MyLocationListener class or declare your MyLocationListener as an abstract class. If you declare MyLocationListener as an abstract class, you will not be able to instantiate it, so it is more likely that you want to implement the method.

Upvotes: 1

Related Questions