使用 Twitter4J 注销不适用于 android [英] signout using Twitter4J is not working with android

查看:41
本文介绍了使用 Twitter4J 注销不适用于 android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 twitter 4j 3.0.2 jar我已将 twitter 集成到我的 android 应用程序中.我已成功登录并将推文发送到推特帐户,但我在注销时遇到问题来自我的 android 应用的 twitter 帐户.

I am using twitter 4j 3.0.2 jar I have integrate twitter in my android app.I have successfully login and send tweet to twitter account but I face issue in logout from twitter account from my android app.

我实现的与 twitter4j 示例应用程序相同,我注意到twitter4j 示例应用中也存在同样的问题.

I implement this as same as twitter4j sample app and I have noticed that same issue also in twitter4j sample app.

我已经完成的步骤

  1. 当我第一次从我的应用点击登录按钮然后登录页面时推特的打开.2.我将令牌保存在 SharedPreferences 中.3.将登录按钮转换为注销.4.现在我点击注销按钮并从共享中清除令牌喜好.5.将注销按钮转换为登录6.再次点击登录,就会打开推特的登录页面而不是授权打开应用页面.

我的主要问题是如何从 android 应用程序从 twitter 注销.是twitter 缓存保存在设备的任何地方?如果是,那么我如何从我的 Android 应用中清除 twitter 缓存.

My main issue is that how to signout from twitter from android app.Is twitter cache is maintained in anywhere in device ? if yes then how I clear twitter cache from my android app.

Editor e = mSharedPreferences.edit();
        e.remove(PREF_KEY_OAUTH_TOKEN);
        e.remove(PREF_KEY_OAUTH_SECRET);
        e.remove(PREF_KEY_TWITTER_LOGIN);
        e.commit();
        //twitter.shutdown();
        twitter = new TwitterFactory().getInstance();
        twitter.setOAuthConsumer(TWITTER_CONSUMER_KEY,TWITTER_CONSUMER_SECRET);

推荐答案

您需要在 twitter 中使用强制登录.详情请看我之前的帖子

You need to use force login in twitter. For more details see my previous post

Twitter 登录对话框错误

所以您只需要在您的授权网址中添加 force_login=true

So you just need to add force_login=true in your authorize url i.e

http://twitter.com/oauth/authorize?force_login=true

这篇关于使用 Twitter4J 注销不适用于 android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆