Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I want to display timeline using a particular screenName i am getting this error:-

Must Initialize Fabric before using singleton()

By the way ,I am suppose to use automatic guest authentication. Here is my Java code:-

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);
    }
}
like image 555
kumar kundan Avatar asked Jul 10 '15 04:07

kumar kundan


2 Answers

I got it solved by myself. Just add below two lines . Do n't forget to edit and paste your 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());

before

final UserTimeline userTimeline = new UserTimeline.Builder().screenName("fabric").build()
like image 76
kumar kundan Avatar answered Nov 04 '22 00:11

kumar kundan


Add this Acitvity onCreate metod

Fabric.with(this, new Crashlytics());
like image 20
Faxriddin Abdullayev Avatar answered Nov 04 '22 01:11

Faxriddin Abdullayev