Android Question IOnActivityResult does not fire...

DevBaby

Active Member
Licensed User
Longtime User
Please Ignore...I found my mistake!!!!!
I did not properly follow Erel's guide.



I have the following code for the Google Game Service Library that fires an ActivityForResult that is launched within Googles's library. Google supplies the requestcode (RC_RESOLVE value = 9001) so i did not need any of the extra code steps to extract it.

I can launch the activity using mConnectionResult.startResolutionForResult(mActivity, RC_RESOLVE);, however when I close the activity, my IOnActivityResult does not fire or seem to capture the return data.

The code in ResultArrived(int resultCode, Intent intent) does not execute.

I used public IOnActivityResult ion; to declare the ion variable.

B4X:
void resolveConnectionResult() {
        // Try to resolve the problem
        checkState(TYPE_GAMEHELPER_BUG, "resolveConnectionResult",
                "resolveConnectionResult should only be called when connecting. Proceeding anyway.",
                STATE_CONNECTING);

        if (mExpectingResolution) {
            debugLog("We're already expecting the result of a previous resolution.");
            return;
        }

        Log.d("b4a", "resolveConnectionResult");

        debugLog("resolveConnectionResult: trying to resolve result: " + mConnectionResult);
        if (mConnectionResult.hasResolution()) {
            // This problem can be fixed. So let's try to fix it.
            debugLog("Result has resolution. Starting it.");
            // launch appropriate UI flow (which might, for example, be the
            // sign-in flow)


            // First, call B4a ION listener
            ion = new IOnActivityResult() {
                @Override
                public void ResultArrived(int resultCode, Intent intent) {
                
                
                    showAlert("B4a", " " + resultCode);
                    BResult(resultCode);

                
                }
            };
        

            BA pba =  mba.processBA; //Create process variable....must ask later

            try {
                pba.startActivityForResult(ion, null); //<-- passing null instead of an intent

            } catch (NullPointerException npe) {
                //required...
            }        
        
        
            try {
                mExpectingResolution = true;
                mConnectionResult.startResolutionForResult(mActivity, RC_RESOLVE);
            } catch (SendIntentException e) {
                // Try connecting again
                debugLog("SendIntentException, so connecting again.");
                connectCurrentClient();
            }

    
        } else {
            // It's not a problem what we can solve, so give up and show an
            // error.
            debugLog("resolveConnectionResult: result has no resolution. Giving up.");
            giveUp(new SignInFailureReason(mConnectionResult.getErrorCode()));
        }
    }
 
Last edited:
Top