Java Question IOnActivityResult ResultArrived not called

warwound

Expert
Licensed User
Longtime User
I'm starting a 3rd party activity from my library code using the BA startActivityForResult method and the activity is failing to call the IOnActivityResult ResultArrived callback method when it finishes.

Here's my library method:

B4X:
public void Check(final BA pBA){
   IOnActivityResult iOnActivityResult=new IOnActivityResult (){
      @Override
      public void ResultArrived(int pResultCode, Intent pIntent) {
         BA.Log("Checkout ResultArrived");
         Log.d("B4A", "Checkout ResultArrived#2");
      }
   };
   Intent intent=getObject().getNewIntent(pBA.context);
   pBA.startActivityForResult(iOnActivityResult, intent);
}

The class that contains this method has the @ActivityObject annotation by the way.
So from B4A i call Check and it starts the 3rd party activity, the activity finishes and the logs always shows:


But the ResultArrived callback never gets executed - i've check the unfiltered logs and there's nothing there.
I've tried this on a Gingerbread and an ICS device - the callback isn't called.

Looking at this thread: http://www.b4x.com/forum/libraries-...-guide-using-onactivityresult.html#post129890, i read:

To avoid memory leaks this method only holds a WeakReference to iOnActivityResult. Which means that you need to hold a strong reference to it in your code.

What does this mean - is it relevant here?

Martin.
 

warwound

Expert
Licensed User
Longtime User
Great - making the IOnActivityResult into a class member fixes it and the callback now executes.

Thanks.

Martin.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…