Monotouch 电话/呼叫状态?
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) 等。
Is there any way in Monotouch to read the current state on the phone or caller service?
Im trying to find some way of reading if a call is active or a call is on hold etc.
Googling on this haven't turned up anything.
Was looking to run some code snippet like:
if(CallIsActive) {
}
else {
}
My solution:
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;
}
}
Run CallHandler.CallCount to get current callcount and GetCallState(0) for first call etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您正在寻找 CoreTelephony 框架。有一个苹果 示例。
您需要将代码从 ObjectiveC 转换为 C#(查找 callStateToUser)。
I think you're looking for the CoreTelephony framework. There is an Apple sample that covers it.
You'll need to convert the code from ObjectiveC to C# (look for callStateToUser).