适用于Android的Twitter Fabric登录 [英] Twitter Fabric Login for Android
问题描述
我正在尝试使用Twitter提供的新Fabric API,以允许用户登录到我的应用程序.我已经完全按照本教程进行了(至少我认为我有,也许我犯了一些错误)此处使用所有必要步骤设置完我的项目后;现在,当我按下登录按钮并进行身份验证时,该按钮会返回成功的响应,但是当我去获取Twitter Session时,我会看到一个类似
I'm attempting to use the new Fabric API that Twitter is offering to let users login to my app. I've followed the tutorial exactly (at least I think I have, maybe I've made some mistakes) here after setting up my project with all of the necessary steps; now when I hit the login button and authenticate the button gives back a successful response but when I go to get the Twitter Session after that I get an exception that looks like
Caused by: java.lang.IllegalStateException: Must start Twitter Kit with Fabric.with() first
(同样,到目前为止,我已按照本教程进行了T练习,但是如果您能想到任何事情,那么我愿意尝试一下)
(again, I followed the tutorial to a T up to this point, but if you can think of anything then I'd be willing to try it)
推荐答案
Fabric SDK将功能分为名为Kits的模块.您必须通过Fabric.with()指明要使用的套件.通常,这是通过扩展Android的Application类来完成的.
The Fabric SDK separates functionality into modules called Kits. You must indicate which kits you wish to use via Fabric.with(). This is typically done by extending Android’s Application class.
package com.example.app;
import android.app.Application;
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
TwitterAuthConfig authConfig =
new TwitterAuthConfig("consumerKey",
"consumerSecret");
Fabric.with(this, new Twitter(authConfig));
// Example: multiple kits
// Fabric.with(this, new Twitter(authConfig),
// new Crashlytics());
}
}
更多信息: https://dev.twitter.com/twitter-kit/android/integrate
在以下位置查看规范的示例应用程序: https://github.com/twitterdev/cannonball-android
See the canonical sample app at: https://github.com/twitterdev/cannonball-android
这篇关于适用于Android的Twitter Fabric登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!