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獲取當前callcount和GetCallState(0),首先調用等
Anders,爲了其他人在StackOverflow上尋找解決方案,你能用自己的帖子回答你自己的問題嗎? –
好吧,當我重新開始工作時,我發佈了我的解決方案! – Anders