简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM