Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter Composer Callback OnSuccess/OnFailure Fabric

I am trying to detect whether the tweet was successful or not. How can this be achieved on Android using the Fabric (Twitter Composer) api?

new TweetComposer.Builder(activity)
                                .text("#hastag").show();

What I want to do:

new TweetComposer.Builder(activity)
                                .text("#hastag").
                                .onSuccess(new Success(....))
                                .onFailure(new Failure(...)
                                .show();

I could listen to the onActivityResult method in the Activity but I was hoping there would be a cleaner and better way.

like image 878
Jon Andersen Avatar asked Dec 02 '22 15:12

Jon Andersen


1 Answers

Instead of using .show(); , create an intent like this :

new Intent i = new TweetComposer.Builder(activity)
                                .text("#hastag").
                                .createIntent();

Now you can start the activity for result :

startActivityForResult(i, TWEETER_REQ_CODE);

where TWEETER_REQ_CODE is just a numerical identifier. next onActivityResult wait for the TWEETER_REQ_CODE to show up.

Hope it helped, N.

like image 173
ntcase Avatar answered Dec 10 '22 13:12

ntcase