Monotouch 有什么方法可以读取电话或呼叫者服务的当前状态吗?
如果通话处于活动状态或通话处于保持状态等,我试图找到某种阅读方式。
谷歌搜索这个没有出现任何东西。
正在寻找运行一些代码片段,例如:
if(CallIsActive) {
}
else {
}
我的解决方案:
public static class CallHandler
{
private static CTCallCenter ctc;
private static NSSet calls;
public static void StartListening() {
Console.WriteLine ("Callhandler is listening");
ctc = new CTCallCenter ();
calls = ctc.CurrentCalls;
ctc.CallEventHandler = new CTCallEventHandler (delegate(CTCall inCTcall) {
calls = ctc.CurrentCalls;
});
}
public static uint CallCount {
get {
return (calls != null) ? calls.Count : 0;
}
}
public static string GetCallState(int CallID) {
CTCall[] callArr = calls.ToArray<CTCall>();
CTCall call = callArr[CallID];
return call.CallState;
}
}
运行 CallHandler.CallCount 以获取当前呼叫计数和 GetCallState(0) 以进行首次呼叫等。