I have a login button in a fragment. The main activity has:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// TWITTER: Pass the activity result to the fragment, which will then pass the result to the login
Fragment fragment1 = mSectionsPagerAdapter.getItem(0); // get the first fragment where twitter is
if(fragment1 != null)
fragment1.onActivityResult(requestCode, resultCode, data);
}
And in the Fragment:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
//twitter
if(loginButton != null)
loginButton.onActivityResult(requestCode, resultCode, data);
}
So it seems like the activity callback setup is OK. My button code is (removing some other stuff):
loginButton = (TwitterLoginButton) rootView.findViewById(R.id.twitter_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
tv_twitter_status.setText("2 Twitter Login in good!");
}
@Override
public void failure(TwitterException exception) {
// Do something on failure
tv_twitter_status.setText("2 ERROR: " + exception.getMessage());
}
}
});
What happens is if I start the app fresh, the login comes up if I have not logged in before and asks for permission for the app. If ok, nothing is called. If I use the button again, either nothing happens or the failure callback is called - without any screen from Twitter. I have never gotten the success callback even when logging in and permitting OK.
I think I have all the keys and permissions correct.If it matters, I am at minSDK 12, build SDK 22, I am wondering about possible mixes or conflicts on v4 and current libraries but it all compiles and runs otherwise.
Also is the login button also used to logout or ?