简体   繁体   English

Azure移动服务Android错误

[英]Azure Mobile Services Android Error

I'm doing an android app and trying to integrate social login into the application using Azure Mobile Services. 我正在做一个android应用程序,并尝试使用Azure移动服务将社交登录集成到该应用程序中。

public class SocialLogin extends Activity implements UserAuthenticationCallback {
            @Override
            protected void onCreate(Bundle savedInstanceState) {
                   // on create code
            }

         // All the code

            @Override
            public void onCompleted(MobileServiceUser user, Exception exception, ServiceFilterResponse response) {
                if (exception == null) {
                    //Take user to the logged in view
                    cacheUserToken(user);
                } else {
                    Log.e("SocialLogin", "User did not login successfully");
                }
            }
}

I'm getting two errors because of the onCompleted method. 由于onCompleted方法,我遇到了两个错误。

Error:(176, 5) error: method does not override or implement a method from a supertype
Error:(37, 8) error: SocialLogin is not abstract and does not override abstract method onCompleted(MobileServiceUser,Exception,ServiceFilterResponse) in UserAuthenticationCallback

Edit: Fixed the problem by deleting away the .jar file in my lib. 编辑:通过删除我的lib中的.jar文件来解决此问题。

Per my understanding, 'UserAuthenticationCallback' is not an interface since many of samples are coding like this: 根据我的理解,“ UserAuthenticationCallback”不是一个接口,因为许多示例都像这样编码:

MobileServiceClient mClient = new MobileServiceClient(
            "MobileServiceUrl",
            "AppKey", 
            this).withFilter(new ProgressFilter());
mClient.login(MobileServiceAuthenticationProvider.MicrosoftAccount,
                new UserAuthenticationCallback() {
                    @Override
                    public void onCompleted(MobileServiceUser user,
                            Exception exception, ServiceFilterResponse response) {

                        synchronized(mAuthenticationLock)
                        {
                            if (exception == null) {
                                cacheUserToken(mClient.getCurrentUser());
                            } else {
                                createAndShowDialog(exception.getMessage(), "Login Error");
                            }

                        }
                    }
                });

Since it is not an interface, we cannot implement it as you did. 由于它不是接口,因此我们无法像您一样实现它。 You can either create a class that inherits UserAuthenticationCallback (but the class cannot inherit Activity as we can only inherit one class), or simply create a new instance of UserAuthenticationCallback like the code in the sample. 您可以创建一个继承UserAuthenticationCallback的类(但该类不能继承Activity,因为我们只能继承一个类),也可以像示例中的代码一样简单地创建UserAuthenticationCallback的新实例。

Also, I'd like to suggest you to check https://azure.microsoft.com/en-us/documentation/articles/mobile-services-android-get-started-users/ and https://azure.microsoft.com/en-us/documentation/articles/mobile-services-android-get-started-data/ for a completed sample of how to add authentication to your Mobile Services Android app. 另外,我建议您检查https://azure.microsoft.com/zh-cn/documentation/articles/mobile-services-android-get-started-users/https://azure.microsoft。 com / en-us / documentation / articles / mobile-services-android-get-started-data /有关如何向您的Mobile Services Android应用添加身份验证的完整示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM