Search code examples
androidandroid-fragmentsandroid-billing

onActivityResult() not called after startIntentSenderForResult()


UPDATE: I have now tried to run the same flow from a regular Activity, and getting the same result - onActivityResult() not fired. Tested on two differenet physical devices (running android 4.4 and 5.1)

Note: This question was asked before, yet this case is different, thus the accepted answer doesn't solve it.

From MainActivity we start a FragmentDialog:

public void ShowDialog(View v)
{
    MyDialog myDialog = new MyDialog();
    myDialog.show(getFragmentManager(),"");
}

Then, from MyDialog we call

PendingIntent pendingIntent = bundle.getParcelable(BUY_INTENT);
        if( null == pendingIntent)  return false;

getActivity().startIntentSenderForResult
                (pendingIntent.getIntentSender(), REQUEST_CODE, new Intent(), 0, 0, 0);

The above indeed invokes the Google Billing Fragment, however, niether MyDialog.onActivityResult() nor MainActivity.onActivityResult() get called.


Solution

  • YGTBFKM!

    After a long kong-fu session, I've finally found that as opposed to the mentioned at the documentation the requestCode used for startIntentSenderForResult() CANNOT BE ARBITRARY! I don't have a specific cutoff number, but values below 1000 seems to work fine.