Return a value from overridden callback - android

I am making a call to get a Firebase token, then using that token to get a token from my server.
I want userSignIn() to return the token from my server.
Does anyone know how can I return the token to userSignIn()?
#Override
public String userSignIn(String email, String password, String authType) throws Exception {
login(email, password, authType, new OnLoginResponseCallback() {
#Override
public String onLoginResponse(boolean success, String token) {
**return token;** // how do I return this to userSignIn???
}
});
}
public interface OnLoginResponseCallback {
public String onLoginResponse(boolean success, String token);
}
public void login(String email, String password, String authType, final OnLoginResponseCallback callback) throws Exception {
getFirebaseToken(email, password, new OnFirebaseTokenResponseCallback() {
#Override
public String onFirebaseTokenResponse(boolean success, String token) {
getAuthToken(token, null, new OnAuthTokenResponseCallback(){
#Override
public String onAuthTokenResponse(boolean success, JSONObject response){
try {
String access_token = response.getString("access_token");
callback.onLoginResponse(true, access_token);
}
catch (JSONException ex) {
}
}
});
}
});
}
public interface OnFirebaseTokenResponseCallback {
public String onFirebaseTokenResponse(boolean success, String token);
}
public void getFirebaseToken(String email, String password, final OnFirebaseTokenResponseCallback callback) {
FirebaseAuth auth = FirebaseAuth.getInstance();
auth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
if (!task.isSuccessful()) {
} else {
AuthResult result = task.getResult();
FirebaseUser user = result.getUser();
user.getToken(false).addOnCompleteListener(new OnCompleteListener<GetTokenResult>() {
#Override
public void onComplete(#NonNull Task<GetTokenResult> task) {
if (task.isSuccessful()) {
try {
String token = task.getResult().getToken();
callback.onFirebaseTokenResponse(true, token);
}
catch (Exception ex) {
}
} else {
}
}
});
}
}
});
}
public interface OnAuthTokenResponseCallback {
public String onAuthTokenResponse(boolean success, JSONObject response);
}
public void getAuthToken(String token, String refreshToken, final OnAuthTokenResponseCallback callback) throws JSONException {
RequestParams params = new RequestParams();
if (refreshToken != null)
{
params.add("grant_type", "refresh_token");
params.add("refresh_token", refreshToken);
}
else if (token != null)
{
params.add("grant_type", "urn:ietf:params:oauth:grant-type:firebase_token");
params.add("assertion", token);
}
else if (refreshToken == null && token == null)
{
params.add("grant_type", "password");
params.add("username", "");
params.add("password", "");
}
AuthClient.post("connect/token", params, new JsonHttpResponseHandler() {
#Override
public void onSuccess(int statusCode, cz.msebera.android.httpclient.Header[] headers, JSONObject response) {
try {
callback.onAuthTokenResponse(true, response);
} catch (Exception ex) {
}
}
#Override
public void onFailure(int statusCode, cz.msebera.android.httpclient.Header[] headers, Throwable throwable, JSONObject response) {
callback.onAuthTokenResponse(false, new JSONObject());
}
});
}
UPDATE:
Thanks. I removed the redundant method, and call login like this:
.login(userName, userPass, mAuthTokenType, new OnLoginResponseCallback() {
#Override
public void onLoginResponse(boolean success, String token) {
data.putString(AccountManager.KEY_ACCOUNT_NAME, userName);
data.putString(AccountManager.KEY_ACCOUNT_TYPE, accountType);
data.putString(AccountManager.KEY_AUTHTOKEN, token);
data.putString(PARAM_USER_PASS, userPass);
}
});
I think it works but haven't had a chance to fully test it yet. One thing I am not certain about is I am trying to modify "data" with a value from "token", yet "data" is a Bundle that is final, so I am not sure if that works or not. Will test later. Thanks.

You called a method that basically calls another method of the same signature
#Override
public String userSignIn(String email, String password, String authType) throws Exception {
login(email, password, authType, new OnLoginResponseCallback() {
#Override
Instead, wherever you would call userSignIn, you call login, and pass in that anonymous class. You can't return from these inner methods, because that isn't how callbacks work. You use the parameters of the interface methods to "continue" your logic. Like, do login, callback to the main function with some user info, use this info to make a new request, have a callback waiting for that data, that passes back data to some other method. It's all void methods calling other methods. No return statements
Although, in Javascript, you can read this
How to return value from an asynchronous callback function?

Why you want to return token from there that's not really clear as you are already under the method !!! You can do rest of the work within onLoginResponse() or by calling another method.

Related

passing the results back to an activity from retrofit async call

i have setup retrofit client and the api interface, i have some code as follows
public Result<LoggedInUser> login(String username, String password) {
try {
apiInterface = ApiClient.getClient().create(ApiInterface.class);
RequestData requestData = new RequestData(username, password);
Call<RequestResponse> call = apiInterface.login(requestData);
call.enqueue(new Callback<RequestResponse>() {
#Override
public void onResponse(Call<RequestResponse> call, Response<RequestResponse> response) {
RequestResponse resource = response.body();
System.out.println(resource.getData().getAccessToken());
}
#Override
public void onFailure(Call<RequestResponse> call, Throwable t) {
call.cancel();
}
});
LoggedInUser fakeUser = new LoggedInUser(
java.util.UUID.randomUUID().toString(),
"Jane Doe");
return new Result.Success<>(fakeUser);
} catch (Exception e) {
return new Result.Error(new IOException("Error logging in", e));
}
}
I am not familar with the pattern that should be used to notify the repository class when the rest call obtains it's response.
the above code is called from the following code in the repository class
public Result<LoggedInUser> login(String username, String password) {
// handle login
Result<LoggedInUser> result = dataSource.login(username, password);
if (result instanceof Result.Success) {
setLoggedInUser(((Result.Success<LoggedInUser>) result).getData());
}
return result;
}

How do I create a session between an Android Application and Django Rest-Auth through Retrofit?

I am able to do the initial log in to the server and get the token, but when I try to do another request I get the HTTP error 403, so I am not actually being authenticated.
When I go through the browser or the android application, this is the key that I am getting when I log in.
{
"key": "64ea43a78fa18da19364d2d0ae5a12371e5d0ee2"
}
Is there anything that I can do with this key using retrofit? I have tried using the header "Authorization" and following with the token.
Here is my RestClient interface:
public interface RestClient {
#POST ("rest-auth/login/")
Call<Token> login(
#Body Login body
);
#GET ("v2/users/{user}/")
Call<List<CustomUser>> getUser(
#Header("Authorization") String token,
#Path("user") String user
);
Here is the AsyncTask which will perform the requests to the server. The authenticateUser gives me an HTTP response of 200, but the syncUser gives 403.
public class ActionSync extends AsyncTask<String, Void, Boolean> {
RestClient client;
IData activity;
private static String token;
public ActionSync(Context context) {
activity = (IData) context;
}
#Override
protected Boolean doInBackground(String... params) {
Retrofit.Builder builder = new Retrofit.Builder()
.baseUrl("http://" + params[2] + ":" + params[3] + "/")
.addConverterFactory(GsonConverterFactory.create());
Retrofit retrofit = builder.build();
client = retrofit.create(RestClient.class);
//Authenticate the user.
authenticateUser(params[0], params[1]);
//Once the authentication has been completed, we can now move on the syncing data.
syncUser(params[0]);
//If we get to the end without any errors, then return true. This means that the sync is complete.
return true;
}
#Override
protected void onPostExecute(Boolean loggedIn) {
super.onPostExecute(loggedIn);
}
public void authenticateUser(String username, String password){
//First, we must log into the server given our credentials. Otherwise, we will not be able to get any data.
Login login = new Login(username, password);
Call<Token> call = client.login(login);
call.enqueue(new Callback<Token>() {
#Override
public void onResponse(Call<Token> call, Response<Token> response) {
if(response.isSuccessful()){
Log.v("ActionSync", "Login was successful");
token = response.body().getKey();
} else {
Log.v("ActionSync", "Login was unsuccessful");
}
}
#Override
public void onFailure(Call<Token> call, Throwable t) {
Log.v("ActionSync", "Error occurred during login");
}
});
}
public void syncUser(String username){
Call<List<CustomUser>> call = client.getUser(token, username);
call.enqueue(new Callback<List<CustomUser>>() {
#Override
public void onResponse(Call<List<CustomUser>> call, Response<List<CustomUser>> response) {
Log.v("ActionSync", "The response from get user: " + response.toString());
}
#Override
public void onFailure(Call<List<CustomUser>> call, Throwable t) {
Log.v("ActionSync", "No response from get user");
}
});
}
public interface IData {
}
}

Retrofit returns not working access token

I'm creating an authorization app, where user registers and gets client_id, client_secret, access_token and refresh_token. I have one API where i need to do call. In that call I use my access_token. All works great. But the access_token expires after hour, so with refresh_token I'm updating my access_token, but the new access_token not works. When I'm doing call with this new access_token, the response body message is "expired access_token provided". In postman all works good. When I'm getting new access_token, in server visible only the access_token that i got from registration. So in server the access_token not updating. But when I'm doing this in postman, the access_token in server changes. So what's the problem, that in postman he updates the access_token, and in server the access_token changes, but when I'm updating in phone, the access_token in server not changes. I done debugging and i see that I'm getting new access_token. So where's the problem?
public interface SupportopApi {
//Post request for user register
#POST("/api/registration")
Call<ResponseBody> registrationRequest(#Body SupportopObjRegistration supportopObjRegistration);
//Post request for user activation
#POST("/api/getClientCD")
Call<ResponseBody> clientActivationRequest(#Body SupportopObjClient activate);
//Get request for getting token
#GET("/api/getToken")
Call<ResponseBody> getTokenRequest(#Query("grant_type") String grant_type,
#Query("client_id") String client_id,
#Query("client_secret") String client_secret,
#Query("email") String email,
#Query("password") String password);
//The call where i use my access_token
#GET("/api/getLanguages")
Call<ResponseBody> getLanguages(#Header("Content-Type") String json,
#Header("Authorization") String token,
#Header("Cache-Control") String cache);}
Here's the retrofit and OkHttpClient initialize part.
public class ApiClient {
private static ApiClient instance;
private SupportopApi supportopApi;
client.addInterceptor(new Interceptor() {
#Override
public Response intercept(#NonNull Chain chain) throws IOException {
Request request = chain.request();
request = request.newBuilder()
.build();
return chain.proceed(request);
}
});
supportopApi = new Retrofit.Builder()
.baseUrl(endpoint)
.client(client.build())
.addConverterFactory(GsonConverterFactory.create())
.build()
.create(SupportopApi.class);
}
public static synchronized void initializeInstance(String endpoint) {
if (instance == null) {
instance = new ApiClient(endpoint);
}
}
public static synchronized ApiClient getInstance() {
if (instance == null) {
throw new IllegalStateException("PentairAPIClient has not been initialized.");
}
return instance;
}
public Call<ResponseBody> registration(SupportopObjRegistration supportopObjRegistration) {
return supportopApi.registrationRequest(supportopObjRegistration);
}
public Call<ResponseBody> activation(SupportopObjClient activate) {
return supportopApi.clientActivationRequest(activate);
}
public Call<ResponseBody> getToken(String grant_type, String client_id, String client_secret,
String email, String password) {
return supportopApi.getTokenRequest(grant_type, client_id, client_secret, email, password);
}
public Call<ResponseBody> getLanguage(String token) {
String new_token = "Bearer " + token;
return supportopApi.getLanguages("application/json", new_token, "no-cache");
}
}
Registration works great, so I'll show you only the login call.
public class LoginFragment extends BaseFragment {
private View mainView;
private ApiClient apiClient;
private EditText email, password;
private Button userLogin;
private SupportopObjClient supportopClientActivate;
#Override
public String toString() {
return "LoginFragment";
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mainView = inflater.inflate(R.layout.login_fragment, container, false);
init(mainView);
return mainView;
}
private void init(final View v) {
apiClient = ApiClient.getInstance();
email = (EditText) v.findViewById(R.id.login_email);
password = (EditText) v.findViewById(R.id.login_password);
userLogin = (Button) v.findViewById(R.id.user_login);
userLogin.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
supportopClientActivate.setUsername("");
supportopClientActivate.setEmail(email.getText().toString());
supportopClientActivate.setPassword(password.getText().toString());
supportopClientActivate.setType("generic");
getClient();
}
});
}
public void getClient() {
Call<ResponseBody> callActive = apiClient.activation(supportopClientActivate);
callActive.enqueue(new Callback<ResponseBody>() {
#Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
if (response.isSuccessful()) {
try {
//Parsing the data from Json to string
String data = response.body().string();
JSONObject obj = new JSONObject(data);
String client_id = obj.getString("client_id");
String client_secret = obj.getString("client_secret");
//Saving clientID and clientSecret in phone storage
SharedPreferencesManager.getInstance().setClientID(client_id);
SharedPreferencesManager.getInstance().setClientSecret(client_secret);
//Calling the tokenCall method to get access token and refresh token
loginCall(client_id, client_secret);
} catch (JSONException | IOException e) {
e.printStackTrace();
}
} else {
//if the response not successful
Toast.makeText(getActivity(), "user doesn't exist", Toast.LENGTH_SHORT).show();
}
}
#Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
Toast.makeText(getActivity(), "An error occurred", Toast.LENGTH_SHORT).show();
}
});
}
public void loginCall(String client_id, final String client_secret) {
Call<ResponseBody> token = apiClient.getToken("password", client_id, client_secret,
supportopClientActivate.getEmail(), supportopClientActivate.getPassword());
token.enqueue(new Callback<ResponseBody>() {
#Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
if (response.isSuccessful()) {
try {
//Parsing the data from Json to string
String dataAccess = response.body().string();
JSONObject obj = new JSONObject(dataAccess);
String access_token = obj.getString("accessToken");
String refresh_token = obj.getString("refreshToken");
Toast.makeText(context, access_token, Toast.LENGTH_SHORT).show();
SharedPreferencesManager.getInstance().setAccessToken(access_token);
SharedPreferencesManager.getInstance().setRefreshToken(refresh_token);
Toast.makeText(context, SharedPreferencesManager.getInstance().getAccessToken(), Toast.LENGTH_SHORT).show();
} catch (IOException | JSONException e) {
e.printStackTrace();
}
} else {
Toast.makeText(getActivity(), "password or email are incorrect or doesn't exist",
Toast.LENGTH_SHORT).show();
}
}
#Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
Toast.makeText(getActivity(), "An error occurred", Toast.LENGTH_SHORT).show();
}
});
}

Twitter - Not able to get followers list in android

Integrate twitter in my app, when user logged in through twitter I show the follower list for sending messages but when called /1.1/followers/list.json API I got the null response , Do I need any permission to access API ?
{protocol=h2, code=400, message=, url=https://api.twitter.com/1.1/followers/list.json?screen_name=(screenname)&cursor=-1&skip_status=true}
loginButton.setCallback(new Callback<TwitterSession>() {
#Override
public void success(Result<TwitterSession> result) {
e("********", "----result--->>>>" + result.response);
/* TwitterSession session = TwitterCore.getInstance().getSessionManager().getActiveSession();
TwitterAuthToken authToken = session.getAuthToken();
String token = authToken.token;
String secret = authToken.secret; */
/***********************After login****************/
APIService inf1 = MyApplication.getRetro(Login.this, "https://api.twitter.com").create(APIService.class);
final Call<JsonElement> res1 = inf1.show("-1","(screenName)",true,false);
// "/1.1/followers/list.json?include_user_entities=false&screen_name=twitterdev&skip_status=true&cursor=-1
res1.enqueue(new retrofit2.Callback<JsonElement>() {
#Override
public void onResponse(#NonNull Call<JsonElement> call, #NonNull Response<JsonElement> response) {
try {
JSONObject mReturn = new JSONObject(response.body().toString());
e("-------->>", "*******onResponse*******"+mReturn);
} catch (Exception e) {
e.printStackTrace();
}
}
#Override
public void onFailure(#NonNull Call<JsonElement> call, #NonNull Throwable t) {
}
});
/************************************************/
}
#Override
public void failure(TwitterException exception) {
// Do something on failure
}
});
API:
#GET("/1.1/followers/list.json")
Call<JsonElement> show( #Query("cursor")String cursor,
#Query("screen_name")String var,
#Query("skip_status")boolean skip_status,
#Query("include_user_entities")boolean include_user_entities);

Can't get List of followers in Twitter using Fabric

I am using Fabric sdk for Twitter. In this I am able to make login request as it's described in its document. Now I wan't to get list of follower of logged in user and show in RecycleView with follower name and profile image. I have tried various solutions like:
private void getFollowersdReq(long userID) {
showProgressDialog();
JsonObjectRequest getRegisterReq = new JsonObjectRequest(Request.Method.GET,
"https://api.twitter.com/1.1/followers/list.json?cursor=-1&&skip_status=true&include_user_entities=false&user_id=" + userID, null,
new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
LogUtils.LOGD("Server Response", response.toString());
hideProgressDialog();
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d("server Error",
"Error: " + error.getMessage());
Toast.makeText(getActivity(),
"Error:" + error.getMessage(), Toast.LENGTH_LONG).show();
hideProgressDialog();
}
}) {
/**
* Passing some request headers
* */
#Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json");
headers.put("Accept", "application/json");
return headers;
}
};
// Adding request to request queue
AppController.getInstance().addToRequestQueue(getRegisterReq, new SignpostUrlStack(twitterToken, secret));
// Cancelling request
// ApplicationController.getInstance().getRequestQueue().cancelAll(tag_json_obj);
}
In above code I am calling Twitter API to get list of followers but in this I am getting error message
{
"errors": [
{
"code": 215,
"message": "Bad Authentication data."
}
]
}
Also I have tried
class MyTwitterApiClient extends TwitterApiClient {
public MyTwitterApiClient(TwitterSession session) {
super(session);
}
public CustomService getCustomService() {
return getService(CustomService.class);
}
public UsersService getUsersService() {
return getService(UsersService.class);
}
}
interface CustomService {
#GET("/1.1/followers/list.json")
void show(#Query("user_id") Long userId,
#Query("screen_name") String var,
#Query("skip_status") Boolean var1,
#Query("include_user_entities") Boolean var2,
#Query("count") Integer var3, Callback<User> cb);
}
interface UsersService {
#GET("/1.1/users/show.json")
void show(#Query("user_id") Long userId,
#Query("screen_name") String screenName,
#Query("include_entities") Boolean includeEntities,
Callback<User> cb);
}
Called this class like:
new MyTwitterApiClient(session).getCustomService().show(userID, null, true, true, 100, new Callback<User>() {
#Override
public void success(Result<User> result) {
LogUtils.LOGI("Get success",result.toString());
}
#Override
public void failure(TwitterException e) {
hideProgressDialog();
}
});
By this method also I am not able to get desired output.
The second method (using TwitterApiClient) is almost correct except for the response data model. Refere https://dev.twitter.com/rest/reference/get/followers/list for the structure of the response. You need to build a data model according to this structure.
Here is the fix :
//data model
public class Followers {
#SerializedName("users")
public final List<User> users;
public Followers(List<User> users) {
this.users = users;
}
}
class MyTwitterApiClient extends TwitterApiClient {
public MyTwitterApiClient(TwitterSession session) {
super(session);
}
public CustomService getCustomService() {
return getService(CustomService.class);
}
}
interface CustomService {#GET("/1.1/followers/list.json")
void show(#Query("user_id") Long userId, #Query("screen_name") String
var, #Query("skip_status") Boolean var1, #Query("include_user_entities") Boolean var2, #Query("count") Integer var3, Callback < Followers > cb);
}
new MyTwitterApiClient(session).getCustomService().show(userID, null, true, true, 100, new Callback < Followers > () {#Override
public void success(Result < Followers > result) {
Log.i("Get success", "" + result.data.users.size());
}
#Override
public void failure(TwitterException e) {
}
});
The above code is working for me. Hope it helps!
MyTwitterApiClient.java
import com.twitter.sdk.android.core.Callback;
import com.twitter.sdk.android.core.TwitterApiClient;
import com.twitter.sdk.android.core.TwitterSession;
import retrofit.client.Response;
import retrofit.http.GET;
import retrofit.http.Query;
public class MyTwitterApiClient extends TwitterApiClient {
public MyTwitterApiClient(TwitterSession session) {
super(session);
}
/**
* Provide CustomService with defined endpoints
*/
public CustomService getCustomService() {
return getService(CustomService.class);
}
}
// example users/show service endpoint
interface CustomService {
#GET("/1.1/followers/ids.json")
void list(#Query("user_id") long id, Callback<Response> cb);
}
MainActivity.java
public class MainActivity extends AppCompatActivity {
// Note: Your consumer key and secret should be obfuscated in your source code before shipping.
private static final String TWITTER_KEY = "YOUR_TWITTER_KEY";
private static final String TWITTER_SECRET = "YOUR_TWITTER_SECRET";
TwitterLoginButton loginButton;
SharedPreferences shared;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
Fabric.with(this, new Twitter(authConfig), new Crashlytics());
setContentView(R.layout.activity_main);
shared = getSharedPreferences("demotwitter", Context.MODE_PRIVATE);
loginButton = (TwitterLoginButton) findViewById(R.id.login_button);
loginButton.setCallback(new Callback<TwitterSession>() {
#Override
public void success(Result<TwitterSession> result) {
// Do something with result, which provides a TwitterSession for making API calls
TwitterSession session = Twitter.getSessionManager()
.getActiveSession();
TwitterAuthToken authToken = session.getAuthToken();
String token = authToken.token;
String secret = authToken.secret;
//Here we get all the details of user's twitter account
System.out.println(result.data.getUserName()
+ result.data.getUserId());
Twitter.getApiClient(session).getAccountService()
.verifyCredentials(true, false, new Callback<User>() {
#Override
public void success(Result<User> userResult) {
User user = userResult.data;
//Here we get image url which can be used to set as image wherever required.
System.out.println(user.profileImageUrl+" "+user.email+""+user.followersCount);
}
#Override
public void failure(TwitterException e) {
}
});
shared.edit().putString("tweetToken", token).commit();
shared.edit().putString("tweetSecret", secret).commit();
TwitterAuthClient authClient = new TwitterAuthClient();
authClient.requestEmail(session, new Callback<String>() {
#Override
public void success(Result<String> result) {
// Do something with the result, which provides the
// email address
System.out.println(result.toString());
Log.d("Result", result.toString());
Toast.makeText(getApplicationContext(), result.data,
Toast.LENGTH_LONG).show();
}
#Override
public void failure(TwitterException exception) {
// Do something on failure
System.out.println(exception.getMessage());
}
});
MyTwitterApiClient apiclients=new MyTwitterApiClient(session);
apiclients.getCustomService().list(result.data.getUserId(), new Callback<Response>() {
#Override
public void failure(TwitterException arg0) {
// TODO Auto-generated method stub
}
#Override
public void success(Result<Response> arg0) {
// TODO Auto-generated method stub
BufferedReader reader = null;
StringBuilder sb = new StringBuilder();
try {
reader = new BufferedReader(new InputStreamReader(arg0.response.getBody().in()));
String line;
try {
while ((line = reader.readLine()) != null) {
sb.append(line);
}
} catch (IOException e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
String result = sb.toString();
System.out.println("Response is>>>>>>>>>"+result);
try {
JSONObject obj=new JSONObject(result);
JSONArray ids=obj.getJSONArray("ids");
//This is where we get ids of followers
for(int i=0;i<ids.length();i++){
System.out.println("Id of user "+(i+1)+" is "+ids.get(i));
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
#Override
public void failure(TwitterException exception) {
// Do something on failure
}
});
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Pass the activity result to the login button.
loginButton.onActivityResult(requestCode, resultCode, data);
}
}

Categories

Resources