TweetComposer.Builder intent returns wrong resultCode when user not previously logged into app



I’m using the following code to trigger a TweetComposer intent and capture its result (detect whether the user posted a tweet or not):

TweetComposer.Builder builder = new TweetComposer.Builder(getContext())
        .image(Uri.fromFile(new File(mImage)));

startActivityForResult(builder.createIntent(), INTENT_TWITTER);

Here’s the handling code with onActivityResult:

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == INTENT_TWITTER && resultCode == Activity.RESULT_OK) {

I’m seeing conflicting behavior in this sequence depending on whether the user was previously logged into the app or not when triggering the Intent.

  1. If the user was logged into the app before the intent was launched, and he/she posts a tweet successfully, the handleSuccessfulTweet(); method is called. This is the correct behavior.

  2. If the user was logged into the app before the intent was launched, and he/she discards the app, the method is not called. This is also the correct behavior.

  3. If the user was not logged into the app, then when the intent is launched, the user is presented with the login screen first, and after that is presented with the composer activity. Regardless of whether he/she discards or posts the tweet, handleSuccessfulTweet(); is never called. In this scenario, resultCode is always RESULT_CANCELED. I don’t think this behavior is correct, as whether the user was logged in or not previous to being presented with the composer UI should have nothing to do with whether posting the tweet was successful or not.

Please advice on whether there is an alternative way to detect whether a tweet was performed or not.

Thanks in advance