show timeline of twitter using fabric : 在使用 singleton() 之前必须初始化 Fabric

show timeline of twitter using fabric : Must Initialize Fabric before using singleton()

我想使用特定的 screenName 显示时间轴我收到此错误:-

Must Initialize Fabric before using singleton()

顺便说一下,我想使用自动访客身份验证。这是我的 Java 代码:-

import android.app.ListActivity;
import android.os.Bundle;

import com.twitter.sdk.android.tweetui.TweetTimelineListAdapter;
import com.twitter.sdk.android.tweetui.UserTimeline;

public class TimelineActivity extends ListActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.timeline);

        final UserTimeline userTimeline = new UserTimeline.Builder()
                .screenName("fabric")
                .build(); //HERE I AM GETTING THIS ERROR
        final TweetTimelineListAdapter adapter = new TweetTimelineListAdapter(this, userTimeline);
        setListAdapter(adapter);
    }
}

我自己解决了。只需在下面添加两行。不要忘记编辑并粘贴您的 Consumer Key (API Key) & Consumer Secret (API Secret).

TwitterAuthConfig authConfig =  new TwitterAuthConfig("add your Consumer Key (API Key) ", "Consumer Secret (API Secret)");
Fabric.with(this, new TwitterCore(authConfig), new TweetUi());

之前

final UserTimeline userTimeline = new UserTimeline.Builder().screenName("fabric").build()

添加此 Activity onCreate 方法

Fabric.with(this, new Crashlytics());