I have a simple test case for testing whether an outgoing call is initiated on a button click or not.
public void testCalling(){
IntentFilter callFilter = new IntentFilter();
callFilter.addAction(Intent.ACTION_CALL);
callFilter.addCategory(Intent.CATEGORY_DEFAULT);
callFilter.addDataScheme("tel:");
ActivityMonitor mMonitor = new ActivityMonitor(callFilter, null, false);
getInstrumentation().addMonitor(mMonitor);
mSolo.clickOnText("CALL");
assertTrue(0 < mMonitor.getHits());
sendKeys(KeyEvent.KEYCODE_ENDCALL);
}
Although the Intent is called(the outgoing call is made), my ActivityMonitor fails to register it. The Stack trace is
05-28 17:11:09.183: I/ActivityManager(71): Starting activity: Intent { act=android.intent.action.CALL dat=tel:+xxxxxxx cmp=com.android.phone/.OutgoingCallBroadcaster }
Please help
The only other resource that i could find was this discussion which ended without any solution on android developers group
I thought to have the same problem. Later I found out that my activity monitor didn't work because robotium registers it's own monitor that always hits, blocking any other monitors including mine.
After having the same issue and playing around a bit, I got it to work.
Take the colon off "tel". Then you should have a hit on your monitor.
public void testMakeCall(){
IntentFilter filter = new IntentFilter(Intent.ACTION_CALL);
filter.addCategory(Intent.CATEGORY_DEFAULT);
filter.addDataScheme("tel");
ActivityMonitor activityMonitor = getInstrumentation().addMonitor(filter, null, false);
makeCall();
assertTrue(activityMonitor.getHits() == 1);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With