【发布时间】:2011-09-14 15:29:16
【问题描述】:
Monotouch 有什么方法可以读取电话或呼叫者服务的当前状态吗?
如果通话处于活动状态或通话处于保持状态等,我试图找到某种读取方式。
谷歌搜索没有发现任何东西。
希望运行一些代码 sn-p,例如:
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) 以进行首次呼叫等。
【问题讨论】:
-
安德斯,为了其他人在 StackOverflow 上寻找解决方案,你能用你自己的帖子回答你自己的问题吗?
-
好的,等我回去工作后再发布我的解决方案!
标签: iphone ios mono xamarin.ios core-telephony