I have been trying to use a normal button to execute the authentication process with the twitter sdk but it does not seem to work. Anyone have tried anything similar?
Well actually there's a way of doing this
private TwitterAuthClient client;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
Fabric.with(this, new Twitter(authConfig));
client = new TwitterAuthClient();
Button customLoginButton = (Button) findViewById(R.id.custom_twitter_login);
customLoginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
client.authorize(LoginActivity.this, new Callback() {
@Override
public void success(Result twitterSessionResult) {
Toast.makeText(LoginActivity.this, "success", Toast.LENGTH_SHORT).show();
}
@Override
public void failure(TwitterException e) {
Toast.makeText(LoginActivity.this, "failure", Toast.LENGTH_SHORT).show();
}
});
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
client.onActivityResult(requestCode, resultCode, data);
}
Be aware, onActivityResult part is very important, you seem to lost it.
here's my xml: