开发者

IntentFilter for address book

I have a question regarding the creation of an IntentFilter. I'm currently writing JUnit-tests for an Android application and want to make use of ActivityMonitors. To be more specific: I want to create an ActivityMonitor which listens for calls to the address book as our Application requests the user to choose a contact from the address book. So I want to mock this by using an 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)开发者_如何学Go;
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 doesn't help. This leads me to the assumption, that my ActivityMonitor/IntentFilter is set up with wrong values.

Maybe someone can help?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜