Alejandro Morán Alejandro Morán - 6 months ago 38
Android Question

Backendless - Ambiguous reference error with Twitter login

I have found a curious behaviour in Backendless Twitter login, two of the available uses of the "loginWithTwitter" method are:

loginWithTwitter(
Activity context,
Map<String, String> twitterFieldsMapping,
AsyncCallback<BackendlessUser> responder,
boolean stayLoggedIn
)


and

loginWithTwitter(
Activity context,
WebView webView,
AsyncCallback<BackendlessUser> responder,
boolean stayLoggedIn
)


Of course it is our choice if we send "twitterFieldsMapping" and "webView" parameters, but if we use it in this way:

Backendless.UserService.loginWithTwitter(
LoginActivity.this,
null,
loginCallback,
true
);


We will get an error because it is an ambiguous reference to loginWithTwitter method.

Error raised in Android Studio:


Error:(69, 32) error: reference to loginWithTwitter is ambiguous, both
method
loginWithTwitter(Activity,WebView,AsyncCallback,boolean)
in UserService and method
loginWithTwitter(Activity,Map,AsyncCallback,boolean)
in UserService match


Am I missing some underlying behaviour here? Facebook and Google+ login methods work perfectly and they have 5 methods each, while Twitter has 8 methods.

Answer

You're correct, passing null would make the call ambiguous, therefore there is another signature which does not take neither WebView nor twitterFieldMappings (which is one of the extra methods in comparison to FB and Google):

public void loginWithTwitter( android.app.Activity context, AsyncCallback<BackendlessUser> responder, boolean stayLoggedIn )