@Override protected void onResume() { super.onResume(); // Check to see if we're resuming after having authenticated with // Twitter if (getIntent().getData() != null) { mOAuthManager.setAccessToken(getIntent()); if (mOAuthManager.loggedIn()) { startHomeActivity(); } else { Toast.makeText(this, "Login failed", Toast.LENGTH_SHORT).show(); mButtonLogin.setVisibility(View.VISIBLE); } } else { // No Intent with a callback Uri was found, so let's just see if // we've already logged in, and if so start the Home activity if (mOAuthManager.loggedIn()) { startHomeActivity(); } else { mButtonLogin.setVisibility(View.VISIBLE); } } }
@Override protected void onCreate(Bundle savedInstanceState) { setContentResId(R.layout.login); super.onCreate(savedInstanceState); mOAuthManager = AuthorizationManager.getInstance(this); mProgressIndicator = (ProgressBar) findViewById(R.id.progress_indicator); mButtonLogin = (Button) findViewById(R.id.button_login); mButtonLogin.setOnClickListener( new OnClickListener() { public void onClick(View v) { mProgressIndicator.setVisibility(View.VISIBLE); mButtonLogin.setVisibility(View.INVISIBLE); authorize(); } }); }