Ophitect
Ophitect

Reputation: 543

Azure Mobile Services Android Error

I'm doing an android app and trying to integrate social login into the application using Azure Mobile Services.

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.

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.

Upvotes: 0

Views: 96

Answers (1)

Ming Xu - MSFT
Ming Xu - MSFT

Reputation: 2116

Per my understanding, 'UserAuthenticationCallback' is not an interface since many of samples are coding like this:

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.

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.

Upvotes: 1

Related Questions