Can I hang up a call programmatically in android?

前端 未结 4 1674
慢半拍i
慢半拍i 2020-12-04 09:00

I hope to block some crank call, so I need to hang up some call programmatically in android.

The following fragment is from How to hang up outgoing call in Android?<

4条回答
  •  既然无缘
    2020-12-04 09:28

    If you are in JUnit test then this is how;

    mInstrumentation = InstrumentationRegistry.getInstrumentation();
    mInstrumentation.getUiAutomation().executeShellCommand( "input keyevent " + KeyEvent.KEYCODE_ENDCALL );
    

    It may work also from outside the test but I haven't tried it.

提交回复
热议问题