本文整理汇总了Java中com.twitter.sdk.android.Twitter类的典型用法代码示例。如果您正苦于以下问题:Java Twitter类的具体用法?Java Twitter怎么用?Java Twitter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Twitter类属于com.twitter.sdk.android包,在下文中一共展示了Twitter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.twitter.sdk.android.Twitter; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
singleton = this;
TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
Fabric.with(this, new Twitter(authConfig));
Stetho.initializeWithDefaults(this);
}
示例2: onCreate
import com.twitter.sdk.android.Twitter; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ButterKnife.bind(this);
if (Twitter.getSessionManager().getActiveSession() != null){
navigateToMainScreen();
}
twitterLoginButton.setCallback(new Callback<TwitterSession>() {
@Override
public void success(Result<TwitterSession> result) {
navigateToMainScreen();
}
@Override
public void failure(TwitterException e) {
String msgError = String.format(getString(R.string.login_error_message),
e.getLocalizedMessage());
Snackbar.make(container, msgError, Snackbar.LENGTH_SHORT).show();
}
});
}
示例3: logout
import com.twitter.sdk.android.Twitter; //导入依赖的package包/类
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();
}
示例4: initUserProfile
import com.twitter.sdk.android.Twitter; //导入依赖的package包/类
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);
}
}
}
示例5: fetchTwitterUserData
import com.twitter.sdk.android.Twitter; //导入依赖的package包/类
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) {
}
});
}
示例6: endSession
import com.twitter.sdk.android.Twitter; //导入依赖的package包/类
@Override
public void endSession() {
if (AccessToken.getCurrentAccessToken() != null) {
LoginManager.getInstance().logOut();
}
TwitterSession twitterSession = TwitterCore.getInstance().getSessionManager().getActiveSession();
if (twitterSession != null) {
clearCookies(getApplicationContext());
Twitter.getSessionManager().clearActiveSession();
Twitter.logOut();
}
startActivity(LoginActivity.makeIntent(this));
finish();
}
示例7: requestTwitterUserData
import com.twitter.sdk.android.Twitter; //导入依赖的package包/类
@Override
public void requestTwitterUserData() {
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;
final String fullName = user.name;
final String userImage = user.profileImageUrl.replace("_normal", "");
loginAsGuestPresenter.twitterUserDataSuccess(fullName, userImage);
}
@Override
public void failure(TwitterException e) {
}
});
}
示例8: requestTwitterEmail
import com.twitter.sdk.android.Twitter; //导入依赖的package包/类
@Override
public void requestTwitterEmail() {
TwitterSession session = Twitter.getSessionManager().getActiveSession();
twitterAuthClient.requestEmail(session, new Callback<String>() {
@Override
public void success(Result<String> result) {
String email = result.data;
loginAsGuestPresenter.twitterEmailSuccess(email);
}
@Override
public void failure(TwitterException exception) {
loginAsGuestPresenter.onGettingEmailError();
}
});
}
示例9: onCreate
import com.twitter.sdk.android.Twitter; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
followersActivity = this;
// initialize session, realm , applicationStatus and wifiInternetConnectivity
TwitterSession session = Twitter.getSessionManager().getActiveSession();
MainApplication mainApplication = MainApplication.getInstance().create(FollowersActivity.this);
realm = mainApplication.getRealm();
applicationStatus = ApplicationStatus.getInstance(FollowersActivity.this);
wifiInternetConnectivity = WifiInternetConnectivity.getInstance(FollowersActivity.this);
//----------------------------------------------------------------------------------------------------------//
// initialize data binding components and support required action bar after making data binding
initDataBinding(session, session.getUserId());
setSupportActionBar(activityFollowersBinding.activityFollowersAppToolbar);
activityFollowersBinding.toolbarTitle.setText(getString(R.string.followers, session.getUserName()));
//----------------------------------------------------------------------------------------------------------//
// set up Followers list and initialize its components
setupListFollowers(activityFollowersBinding.activityFollowersRecyclerView);
//----------------------------------------------------------------------------------------------------------//
}
示例10: disconnectTwitter
import com.twitter.sdk.android.Twitter; //导入依赖的package包/类
private void disconnectTwitter(PDRealmUserTwitter twitterParams, final int position) {
PDAPIClient.instance().disconnectTwitterAccount(twitterParams.getAccessToken(), twitterParams.getAccessSecret(), twitterParams.getTwitterId(), new PDAPICallback<PDUser>() {
@Override
public void success(PDUser user) {
PDUtils.updateSavedUser(user);
Twitter.getSessionManager().clearActiveSession();
Twitter.logOut();
Toast.makeText(PDUISettingsActivity.this, "Twitter disconnected.", Toast.LENGTH_SHORT).show();
abraLog(PDAbraConfig.ABRA_EVENT_DISCONNECT_SOCIAL_ACCOUNT, PDAbraConfig.ABRA_PROPERTYVALUE_SOCIAL_NETWORK_TWITTER);
}
@Override
public void failure(int statusCode, Exception e) {
PDLog.d(PDUISettingsActivity.class, "disconnectTwitter:error: " + statusCode + " msg: " + e.getLocalizedMessage());
mItems.get(position).setValidated(true);
mAdapter.notifyItemChanged(position);
}
});
}
示例11: onOptionsItemSelected
import com.twitter.sdk.android.Twitter; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_logout) {
PreferencesHelper.setLoginCheck(false);
Twitter.getSessionManager().clearActiveSession();
Twitter.logOut();
Intent i=new Intent(MyTweetsListActivity.this,LoginActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
finish();
overridePendingTransition(R.anim.activity_slide_in_left, R.anim.activity_slide_out_left);
return true;
}
return super.onOptionsItemSelected(item);
}
示例12: onCreate
import com.twitter.sdk.android.Twitter; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
Realm.init(this);
globalContext = this.getApplicationContext();
TwitterAuthConfig authConfig = new TwitterAuthConfig(getString(R.string.twitter_key),getString(R.string.twitter_secret));
Fabric.with(this, new Twitter(authConfig));
facebookInit();
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
Stetho.initialize(
Stetho.newInitializerBuilder(this)
.enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
.enableWebKitInspector(RealmInspectorModulesProvider.builder(this).build())
.build());
Dexter.initialize(this);
}
示例13: onCreate
import com.twitter.sdk.android.Twitter; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
TwitterAuthConfig authConfig = new TwitterAuthConfig(Constants.TWITTER_KEY, Constants.TWITTER_SECRET);
Fabric.with(this, new Twitter(authConfig));
FacebookSdk.sdkInitialize(getApplicationContext());
boolean isDebuggable = (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));
if (isDebuggable) {
Timber.plant(new Timber.DebugTree());
}
mApplicationComponent = DaggerApplicationComponent.builder().applicationModule(new ApplicationModule(this)).build();
mApplicationComponent.inject(this);
}
示例14: onCreate
import com.twitter.sdk.android.Twitter; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
setupTimber();
// Note: Your consumer key and secret should be obfuscated in your source code before shipping.
if (!TextUtils.isEmpty(BuildConfig.TWITTER_KEY)) {
TwitterAuthConfig authConfig = new TwitterAuthConfig(BuildConfig.TWITTER_KEY, BuildConfig.TWITTER_SECRET);
Fabric.with(this, new Twitter(authConfig), new Crashlytics());
} else {
Fabric.with(this, new Crashlytics());
}
FacebookSdk.sdkInitialize(getApplicationContext());
DBManager.getInstance().init(this);
mAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build();
String url = BuildConfig.WS_PROTOCOL + "://" + BuildConfig.WS_HOST + BuildConfig.WS_PATH;
mAppComponent.plus(new RocketModule(url)).inject(this);
}
示例15: extractUserFromSession
import com.twitter.sdk.android.Twitter; //导入依赖的package包/类
/**
* If an active session is in SessionManager, the method extract the current user associated at
* this.
*/
public static void extractUserFromSession(){
Twitter.getApiClient(Twitter.getSessionManager().getActiveSession()).getAccountService()
.verifyCredentials(true, false, new Callback<User>() {
@Override
public void success(Result<User> userResult) {
TwitterUserTask.CURRENT_USER.set(userResult.data);
}
@Override
public void failure(TwitterException e) {
Log.d("TwitterSession", "Can't found the current user from active session");
}
});
}