Skip to content

Instantly share code, notes, and snippets.

@lethargicpanda
Last active December 24, 2015 06:29
Show Gist options
  • Save lethargicpanda/6757287 to your computer and use it in GitHub Desktop.
Save lethargicpanda/6757287 to your computer and use it in GitHub Desktop.
Check if there is at least one user authenticated on Twitter. Note: this can work for any other app using the AccountManager for the authentication if you pass the right "type". e.g. for vine: "co.vine.android.auth" e.g. for linkedin: "com.linkedin.android"
public boolean isTwitterSignedIn(){
AccountManager manager = AccountManager.get(this);
Account[] account = manager.getAccountsByType("com.twitter.android.auth.login");
if (account.length > 0) {
Log.d("MainActivity", "Authenticated on twitter!");
return true;
} else {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment