pubnub api回调方法错误不会覆盖其超类的方法

时间:2014-11-21 14:24:56

标签: java android

我在我的Android应用程序中使用pubnub api进行聊天功能,subscribe()的代码就是这样的

public void subscribe() {

        try {
            pubnub.subscribe(channel, new Callback() {
                @Override
                public void connectCallback(String channel,
                                             Object message) {
                    notifyUser("SUBSCRIBE : CONNECT on channel:"
                            + channel
                            + " : "
                            + message.getClass()
                            + " : "
                            + message.toString());
                    Log.d(TAG, "SUBSCRIBE : CONNECT on channel:" + message.toString());
                }

                @Override
                public void disconnectCallback(String channel,
                                               Object message) {
                    notifyUser("SUBSCRIBE : DISCONNECT on channel:"
                            + channel
                            + " : "
                            + message.getClass()
                            + " : "
                            + message.toString());
                    Log.d(TAG,"SUBSCRIBE : DISCONNECT on channel:" + message.toString());
                }

                @Override
                public void reconnectCallback(String channel,
                                              Object message) {
                    notifyUser("SUBSCRIBE : RECONNECT on channel:"
                            + channel
                            + " : "
                            + message.getClass()
                            + " : "
                            + message.toString());
                    Log.d(TAG,"SUBSCRIBE : RECONNECT on channel:" + message.toString());
                }

                @Override
                public void successCallback(String channel,
                                            Object message) {
                    notifyUser("SUBSCRIBE : " + channel + " : "
                            + message.getClass() + " : "
                            + message.toString());
                    Log.d(TAG,"SUBSCRIBE : " + channel + message.toString());
                }


                @Override
                public void errorCallback(String channel,
                                          PubnubError error) {
                    notifyUser("SUBSCRIBE : ERROR on channel "
                            + channel + " : "
                            + error.toString());
                    Log.d(TAG, "SUBSCRIBE : ERROR on channel " + error.toString());
                }
            });

        } catch (Exception e) {

        }
    }

但我收到了method does not override method from its superclassmethod successcallback() is never used被覆盖的方法的错误?有人可以解释这些错误以及如何删除它们吗?感谢。

1 个答案:

答案 0 :(得分:0)

由于错误导入回调而出现错误。为了使这些api工作,我们需要导入pubnub“com.pubnub.api.Callback”提供的回调类。