Android的@Override错误 [英] Android @Override error

查看:133
本文介绍了Android的@Override错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,我终于得到了我的Facebook的实施工作,当我开始实现它在我的应用我克服@覆盖以下错误。

Today I've finally got my facebook implementation working and when I started to implement it in my application I get the following errors over @Override.

型的方法的onComplete(捆绑)
  FBConnectionActivity.LoginDialogListener
  必须重写超类方法

The method onComplete(Bundle) of type FBConnectionActivity.LoginDialogListener must override a superclass method

如果我删除@覆盖错误是解决了,但我想明白为什么它是在一个应用程序抱怨这个,而不是其他。

If I remove the @Override the error is solved, but I would like to understand why it is complaining about this in one application and not the other.

我有以下code。

public abstract class FBConnectionActivity extends Activity {

private class LoginDialogListener implements DialogListener {

        @Override
        public void onComplete(Bundle values) {
                Log.d(TAG, "LoginONComplete");
                String token = mFacebook.getAccessToken();
                long token_expires = mFacebook.getAccessExpires();
                Log.d(TAG, "AccessToken: " + token);
                Log.d(TAG, "AccessExpires: " + token_expires);
                sharedPrefs = PreferenceManager
                                .getDefaultSharedPreferences(mContext);
                sharedPrefs.edit().putLong("access_expires", token_expires)
                                .commit();
                sharedPrefs.edit().putString("access_token", token).commit();
                mAsyncRunner.request("me", new IDRequestListener());
        }

        @Override
        public void onFacebookError(FacebookError e) {
                Log.d(TAG, "FacebookError: " + e.getMessage());
        }

        @Override
        public void onError(DialogError e) {
                Log.d(TAG, "Error: " + e.getMessage());
        }

        @Override
        public void onCancel() {
                Log.d(TAG, "OnCancel");
        }
}

...

}

这是只有code,其中的错误确实发生的一部分。但是,这并不在一个应用程序中的任何错误,确实有其他错误。

This is only a part of the code where the error does occur. But this doesn't have any errors in one application and does have errors in the other.

经过一番搜索,我发现,他们已经改变了Java 5和6之间的东西,但是我想,我在Eclipse应用程序中使用同一个Java环境。

After some searching I've found that they've change something between Java 5 and 6. But I suppose that my application in eclipse use the same java environment.

希望有人能解释这是为什么。

Hopefully someone can explain why this is.

非常感谢!

推荐答案

通常该消息将表明你的方法签名从它覆盖方法不同。不过,在看<一个href=\"https://github.com/facebook/facebook-android-sdk/blob/master/facebook/src/com/facebook/android/Facebook.java\">source对于DialogListener ,你的方法看起来是正确的。

Normally that message would indicate that your method signature differs from the method that it is overriding. However, looking at the source for DialogListener, your methods look correct.

在Java 5中,你不能与实现的接口,只从一个超类方法的实际覆盖方法使用 @覆盖注释。这改变了Java 6中,这样你就可以在两种情况下使用它。

In Java 5 you could not use the @Override annotation with methods that implemented an interface, only with actual overrides of methods from a super class. This changed in Java 6 so that you can now use it in both contexts.

如果您正在使用Java 5的编制(或设置编译器的 -source 选项指望Java 5中源),可能是这个问题的原因(如果它应该抱怨所有的4种方法)。在这种情况下,唯一的解决办法是删除注释

If you are compiling with Java 5 (or setting the compiler's -source option to expect Java 5 source) that might be the cause of the problem (if it is it should be complaining about all 4 methods). In this case the only solution is to remove the annotations.

这篇关于Android的@Override错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆