Search code examples
androidtwitterviewtweets

TweetView cause ANR when first appear on screen


I use 3.0.0 version of Android Twitter SDK, init with:

        TwitterConfig config = new TwitterConfig.Builder(this)
                .twitterAuthConfig(new TwitterAuthConfig(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET))
                .logger(new DefaultLogger(Log.INFO))
                .debug(false)
                .build();
        Twitter.initialize(config);

and simple create with:

    CompactTweetView tweetView = new CompactTweetView(activity, getTweetJsonData());
    tweetView.setTweetActionsEnabled(true);

in RecyclerView, and after i going to this screen with CompactTweetView i got ANR problem around 15-20 secs. Only for first time in app instance, secondary and other items shows instantly. If i close and open screen again items also show instantly.


Solution

  • The problem was been in sdk-init:

    Twitter.initialize(config);
    

    That i call in NOT ui-thread (i call it in AsyncTask), after i change to Application.onCreate() method, problem has been solved