Monotouch 电话/呼叫状态?

发布于 2024-12-03 02:24:43 字数 985 浏览 1 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡忘如思 2024-12-10 02:24:43

我认为您正在寻找 CoreTelephony 框架。有一个苹果 示例

using block-based event handlers to receive call events and carrier changes.

您需要将代码从 ObjectiveC 转换为 C#(查找 callStateToUser)。

I think you're looking for the CoreTelephony framework. There is an Apple sample that covers it.

using block-based event handlers to receive call events and carrier changes.

You'll need to convert the code from ObjectiveC to C# (look for callStateToUser).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文