com.twitter.sdk.android.Twitter Java Examples
The following examples show how to use
com.twitter.sdk.android.Twitter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AboutActivity.java From cannonball-android with Apache License 2.0 | 6 votes |
private void setUpSignOut() { final TextView bt = (TextView) findViewById(R.id.deactivate_accounts); bt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Twitter.getSessionManager().clearActiveSession(); Digits.getSessionManager().clearActiveSession(); SessionRecorder.recordSessionInactive("About: accounts deactivated"); Answers.getInstance().logLogin(new LoginEvent().putMethod("Twitter").putSuccess(false)); Answers.getInstance().logLogin(new LoginEvent().putMethod("Digits").putSuccess(false)); Toast.makeText(getApplicationContext(), "All accounts are cleared", Toast.LENGTH_SHORT).show(); } }); }
Example #2
Source File: LoginMaster.java From uPods-android with Apache License 2.0 | 6 votes |
public void logout() { if (AccessToken.getCurrentAccessToken() != null) { LoginManager.getInstance().logOut(); Logger.printInfo(LOG_TAG, "Loged out from facebook"); } if (Twitter.getSessionManager().getActiveSession() != null) { Twitter.getSessionManager().clearActiveSession(); Twitter.logOut(); Logger.printInfo(LOG_TAG, "Loged out from twitter"); } if (VKSdk.isLoggedIn()) { VKSdk.logout(); Logger.printInfo(LOG_TAG, "Loged out from vk"); } Prefs.remove(SyncMaster.GLOBAL_TOKEN); userProfile = new UserProfile(); }
Example #3
Source File: LoginMaster.java From uPods-android with Apache License 2.0 | 6 votes |
public void initUserProfile(final IOperationFinishWithDataCallback profileFetched, boolean isForceUpdate) { if (userProfile != null && !isForceUpdate) { profileFetched.operationFinished(userProfile); } else if (!isLogedIn()) { userProfile = new UserProfile(); profileFetched.operationFinished(userProfile); } else { if (AccessToken.getCurrentAccessToken() != null) { fetchFacebookUserData(profileFetched); } else if (Twitter.getSessionManager().getActiveSession() != null) { fetchTwitterUserData(profileFetched); } else if (VKSdk.isLoggedIn()) { fetchVkUserData(profileFetched); } } }
Example #4
Source File: LoginMaster.java From uPods-android with Apache License 2.0 | 6 votes |
private void fetchTwitterUserData(final IOperationFinishWithDataCallback profileFetched) { TwitterSession session = Twitter.getSessionManager().getActiveSession(); Twitter.getApiClient(session).getAccountService() .verifyCredentials(true, false, new Callback<User>() { @Override public void success(Result<User> userResult) { User user = userResult.data; userProfile = new UserProfile(); userProfile.setName(user.screenName); String profileImage = user.profileImageUrlHttps; profileImage = profileImage.replace("_normal", ""); userProfile.setProfileImageUrl(profileImage); profileFetched.operationFinished(userProfile); } @Override public void failure(TwitterException e) { } }); }
Example #5
Source File: App.java From cannonball-android with Apache License 2.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); singleton = this; extractAvenir(); authConfig = new TwitterAuthConfig(BuildConfig.CONSUMER_KEY, BuildConfig.CONSUMER_SECRET); Fabric.with(this, new Crashlytics(), new Digits(), new Twitter(authConfig), new MoPub()); Crashlytics.setBool(CRASHLYTICS_KEY_CRASHES, areCrashesEnabled()); }
Example #6
Source File: InitialActivity.java From cannonball-android with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Session activeSession = SessionRecorder.recordInitialSessionState( Twitter.getSessionManager().getActiveSession(), Digits.getSessionManager().getActiveSession() ); if (activeSession != null) { startThemeActivity(); } else { startLoginActivity(); } }
Example #7
Source File: InitContentProvider.java From white-label-event-app with Apache License 2.0 | 5 votes |
private void initFabric() { // Only initialize Fabric if Twitter integration is fully configured TwitterConfig.init(context); TwitterConfig config = TwitterConfig.getInstance(); if (config.isConfigured()) { logger.info("Event hashtag is " + config.getEventHashtag() + ". Initializing Fabric."); TwitterAuthConfig auth = new TwitterAuthConfig(config.getApiKey(), config.getApiSecret()); Fabric.with(context, new Twitter(auth)); } else { logger.info("Twitter integration is not configured; Fabric not initialized"); } }
Example #8
Source File: LoginActivity.java From photosearcher with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TwitterSession session = Twitter.getSessionManager().getActiveSession(); if (session != null) { startActivity(MainActivity.createIntent(this)); finish(); } setContentView(R.layout.activity_login); ButterKnife.bind(this); mLoginButton.setCallback(new Callback<TwitterSession>() { @Override public void success(Result<TwitterSession> result) { Timber.d("Authorization succeeded"); Timber.d("name: %s", result.data.getUserName()); mLoginButton.setVisibility(View.GONE); startActivity(MainActivity.createIntent(LoginActivity.this)); finish(); } @Override public void failure(TwitterException e) { Timber.e(e, e.getMessage()); } }); }
Example #9
Source File: AppLifecycleCallbacks.java From photosearcher with Apache License 2.0 | 5 votes |
/** * setup Twitter, Crashlytics */ protected void setupFabric() { TwitterAuthConfig authConfig = new TwitterAuthConfig( BuildConfig.TWITTER_API_KEY, BuildConfig.TWITTER_API_SECRET); Fabric.with(mApp, new Twitter(authConfig), new Crashlytics()); }
Example #10
Source File: LoginMaster.java From uPods-android with Apache License 2.0 | 5 votes |
public String getSecret() { if (Twitter.getSessionManager().getActiveSession() != null) { TwitterSession session = Twitter.getSessionManager().getActiveSession(); TwitterAuthToken authToken = session.getAuthToken(); return authToken.secret; } return ""; }
Example #11
Source File: LoginMaster.java From uPods-android with Apache License 2.0 | 5 votes |
public String getToken() { if (Prefs.getString(SyncMaster.GLOBAL_TOKEN, null) != null) { return Prefs.getString(SyncMaster.GLOBAL_TOKEN, null); } else if (AccessToken.getCurrentAccessToken() != null) return AccessToken.getCurrentAccessToken().getToken(); else if (Twitter.getSessionManager().getActiveSession() != null) { TwitterSession session = Twitter.getSessionManager().getActiveSession(); TwitterAuthToken authToken = session.getAuthToken(); return authToken.token; } else return VKAccessToken.currentToken().accessToken; }
Example #12
Source File: LoginMaster.java From uPods-android with Apache License 2.0 | 5 votes |
public String getLoginType() { if (Prefs.getString(SyncMaster.GLOBAL_TOKEN, null) != null) { return SyncMaster.TYPE_GLOBAL; } else if (AccessToken.getCurrentAccessToken() != null) return SyncMaster.TYPE_FB; else if (Twitter.getSessionManager().getActiveSession() != null) { return SyncMaster.TYPE_TWITTER; } else return SyncMaster.TYPE_VK; }
Example #13
Source File: TwitterLoginActivity.java From endpoints-samples with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Configure Twitter SDK TwitterAuthConfig authConfig = new TwitterAuthConfig( getString(R.string.twitter_consumer_key), getString(R.string.twitter_consumer_secret)); Fabric.with(this, new Twitter(authConfig)); // Inflate layout (must be done after Twitter is configured) setContentView(R.layout.activity_twitter); // Views mStatusTextView = (TextView) findViewById(R.id.status); mDetailTextView = (TextView) findViewById(R.id.detail); findViewById(R.id.button_twitter_signout).setOnClickListener(this); // [START initialize_auth] // Initialize Firebase Auth mAuth = FirebaseAuth.getInstance(); // [END initialize_auth] // [START auth_state_listener] mAuthListener = new FirebaseAuth.AuthStateListener() { @Override public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { FirebaseUser user = firebaseAuth.getCurrentUser(); if (user != null) { // User is signed in Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid()); } else { // User is signed out Log.d(TAG, "onAuthStateChanged:signed_out"); } // [START_EXCLUDE] updateUI(user); // [END_EXCLUDE] } }; // [END auth_state_listener] // [START initialize_twitter_login] mLoginButton = (TwitterLoginButton) findViewById(R.id.button_twitter_login); mLoginButton.setCallback(new Callback<TwitterSession>() { @Override public void success(Result<TwitterSession> result) { Log.d(TAG, "twitterLogin:success" + result); handleTwitterSession(result.data); } @Override public void failure(TwitterException exception) { Log.w(TAG, "twitterLogin:failure", exception); updateUI(null); } }); // [END initialize_twitter_login] }
Example #14
Source File: TwitterLoginActivity.java From endpoints-samples with Apache License 2.0 | 4 votes |
private void signOut() { mAuth.signOut(); Twitter.logOut(); updateUI(null); }
Example #15
Source File: LoginMaster.java From uPods-android with Apache License 2.0 | 4 votes |
public boolean isLogedIn() { return AccessToken.getCurrentAccessToken() != null || Twitter.getSessionManager().getActiveSession() != null || VKSdk.isLoggedIn(); }
Example #16
Source File: LoginMaster.java From uPods-android with Apache License 2.0 | 4 votes |
private void initTwitter() { TwitterAuthConfig authConfig = new TwitterAuthConfig(Config.TWITTER_CONSUMER_KEY, Config.TWITTER_CONSUMER_SECRET); Fabric.with(UpodsApplication.getContext(), new Twitter(authConfig)); }
Example #17
Source File: TwitterHelper.java From social-login-helper-Deprecated- with MIT License | 4 votes |
public void performSignIn(Context context) { TwitterAuthConfig authConfig = new TwitterAuthConfig(mTwitterApiKey, mTwitterSecreteKey); Fabric.with(context, new Twitter(authConfig)); mAuthClient.authorize(mActivity, mCallback); }