Search code examples
javaandroidobservablelistener

Unable to Create Listener - Trouble Passing Arguments


I'm attempting to create and access a listener in my Observable class from my primary activity using the following:

BlePropertyObservable.getInstance().addListener(this, bleIDs)

Observable Class:

public synchronized void addListener(BleEvent listener, BleEventImp eventIds[]) {
    if (null == listener || null == eventIds) return;
    for (BleEventImp id : eventIds) {
        map.put(id, listener);
    }
}

Interface:

public interface BleEvent {

    void updateView(BleEventImp eventId, String action, Object... obj);
}

However I'm getting an error stating: 'None of the following functions can be called with the arguments supplied:' and I'm unsure how I can go about resolving this.

Any suggestions are appreciated.


Solution

  • As I see BlueToothDriverActivity doesn't implement BleEvent interface. You need to implement it and then you can pass this to the addListener(BleEvent listener, BleEventImp eventIds[]) as listener.