about Instrumentation.ActivityMonitor for Android

637 views Asked by At
Instrumentation.ActivityMonitor (IntentFilter which, 
            Instrumentation.ActivityResult result, 
            boolean block)

from this this Documentation

Instrumentation.ActivityMonitor has 3 parameters. I really don't understand the 2nd parameter. According to the documentation, the result will be returned when the monitor is hit.

My question is where the monitor returns the result to. I thought that it would be returned to onActivityResult() of the activity that started the activity associated the monitor, but it's not.

Does anyone have any advice on it?

2

There are 2 answers

0
Raju On

May be your result return null as per document it says "Retrieve the result associated with this ActivityMonitor, or null if none." then it returned into

Instrumentation.ActivityResult (int resultCode, 
            Intent resultData)

here you can get the result using this method

getResultCode()

just try and let me know

0
Min Hwang On

After spending some time to understand the document, I finally have figured it out. Please refer to my own example code at github, https://github.com/minhwang/activity_monitor_example

I can use the second parameter when the activity being monitored is started by startActivityForResult() method. The parameter will be passed to the onActivityResult() of the activity that have started the activity.