这是我的堆栈跟踪,我不知道出了什么问题!
08-30 12:26:50.494: E/AndroidRuntime(19465): FATAL EXCEPTION: main
08-30 12:26:50.494: E/AndroidRuntime(19465): java.lang.IllegalArgumentException: Invalid access token format.
08-30 12:26:50.494: E/AndroidRuntime(19465): at twitter4j.auth.AccessToken.<init>(AccessToken.java:50)
08-30 12:26:50.494: E/AndroidRuntime(19465): at com.project.p.twitter.TwitterUtils.isAuthenticated(TwitterUtils.java:21)
08-30 12:26:50.494: E/AndroidRuntime(19465): at com.project.p.activities.Activity$4.onClick(Activity.java:313)
08-30 12:26:50.494: E/AndroidRuntime(19465): at android.view.View.performClick(View.java:3591)
08-30 12:26:50.494: E/AndroidRuntime(19465): at android.view.View$PerformClick.run(View.java:14263)
08-30 12:26:50.494: E/AndroidRuntime(19465): at android.os.Handler.handleCallback(Handler.java:605)
08-30 12:26:50.494: E/AndroidRuntime(19465): at android.os.Handler.dispatchMessage(Handler.java:92)
08-30 12:26:50.494: E/AndroidRuntime(19465): at android.os.Looper.loop(Looper.java:137)
08-30 12:26:50.494: E/AndroidRuntime(19465): at android.app.ActivityThread.main(ActivityThread.java:4507)
08-30 12:26:50.494: E/AndroidRuntime(19465): at java.lang.reflect.Method.invokeNative(Native Method)
08-30 12:26:50.494: E/AndroidRuntime(19465): at java.lang.reflect.Method.invoke(Method.java:511)
08-30 12:26:50.494: E/AndroidRuntime(19465): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
08-30 12:26:50.494: E/AndroidRuntime(19465): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
08-30 12:26:50.494: E/AndroidRuntime(19465): at dalvik.system.NativeStart.main(Native Method)
它指向我这段代码
public static boolean isAuthenticated(SharedPreferences prefs) {
String token = prefs.getString(OAuth.OAUTH_TOKEN, "");
String secret = prefs.getString(OAuth.OAUTH_TOKEN_SECRET, "");
AccessToken a = new AccessToken(token, secret);
Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer(Constants.CONSUMER_KEY,
Constants.CONSUMER_SECRET);
twitter.setOAuthAccessToken(a);
try {
twitter.getAccountSettings();
return true;
} catch (TwitterException e) {
return false;
}
}
特别是这条线
AccessToken a = new AccessToken(token, secret);
当我使用 twitter4j 2.1.1 时一切正常,但由于其他原因我不得不更新