Twitter Android SDK does not call back

I am running this code using a Twitter descriptor, which I am sure does not exist to check for error handling. Breakpoints in the callback never hit, either for success or for failure.

Any pointers to why this is?

As a note, this code works fine with a valid Twitter type, but does not call Callback.

final Callback<Tweet> actionCallback = new Callback<Tweet>() { @Override public void success(Result<Tweet> result) { int x = 1; x++; // This code is just so I can put a breakpoint here } @Override public void failure(TwitterException exception) { DialogManager.showOkDialog(context, R.string.twitter_feed_not_found); } }; final UserTimeline userTimeline = new UserTimeline.Builder().screenName(handleStr + "dfdfddfdfdfasdf") // Handle that doesn't exist .includeReplies(false).includeRetweets(false).maxItemsPerRequest(5).build(); final TweetTimelineListAdapter adapter = new TweetTimelineListAdapter.Builder(context) .setTimeline(userTimeline) .setViewStyle(R.style.tw__TweetLightWithActionsStyle) .setOnActionCallback(actionCallback) .build(); listView.setAdapter(adapter); 
+7
java android callback twitter android-adapter
source share
1 answer

I think you misunderstood the purpose of actionCallback. From the TweetTimelineListAdapter source code, you can see that this callback is for actions in the tweet view, i.e. When you click on your favorite icon, for example. I have a test with a favorite icon and the calling call is being called.

Take a look at this comment in the getView method of the source code.

  /** * Returns a CompactTweetView by default. May be overridden to provide another view for the * Tweet item. If Tweet actions are enabled, be sure to call setOnActionCallback(actionCallback) * on each new subclass of BaseTweetView to ensure proper success and failure handling * for Tweet actions (favorite, unfavorite). */ 

The callback is not intended to handle a screen name that does not exist, and indeed the action / button of a specific tweet.

Hope this helps.

UPDATED: you do not need to detect any erros in UserTimeLine, since the builder does not throw any exceptions and the adapter will be empty, without any lines / views displayed on the screen. But if you still need to find some “error” in the download, you will have to rely on the “next” UserTimeLine method.

Take a look

  userTimeline.next(null, new Callback<TimelineResult<Tweet>>() { @Override public void success(Result<TimelineResult<Tweet>> result) { } @Override public void failure(TwitterException exception) { Log.d("TAG",exception.getMessage()); } }); 

This method shows the next tweet to the user, if the callback is refused, you know for sure that this user does not have a tweet or the user does not exist.

+3
source share

All Articles