IntentFilter for address book

I have a question about creating IntentFilter

. I am currently writing JUnit tests for an android app and want to use ActivityMonitors

. To be more specific: I want to create ActivityMonitor

one that listens for calls in the address book, since our application asks the user to select a contact from the address book. So I want to mock this by using ActivityMonitor

. This is what I have done so far:

ActivityMonitor addressBookMonitor = null;
try {
        addressBookMonitor = getInstrumentation().addMonitor(new IntentFilter(Intent.ACTION_PICK,"content://contacts/people/"), null, false);
    } catch (MalformedMimeTypeException e) {
        e.printStackTrace();
    }
//code to open the address book
Activity addressBook = getInstrumentation().waitForMonitorWithTimeout(addressBookMonitor, 250);
assertNotNull(addressBook);

      

The problem is that the assertion always fails, although I can see the address book opening in front of our application. Even increasing the timeout value does not help. This leads me to assume mine is ActivityMonitor

/ is IntentFilter

configured with the wrong values.

Can anyone please help?

+2


a source to share





All Articles