uwpwindows-10-mobilec++-cx

UWP.C++.PhoneCallManager.CallStateChanged Register for My Events


how we can PhoneCallManager.CallStateChanged Register for My Events in C++ ? I can make a DIRECT Phone call, but when call is not active i need to exit my App.

PhoneCallManager.CallStateChanged += PhoneCallManager_CallStateChanged;
private async void PhoneCallManager_CallStateChanged(object sender, object e)
{
if (callCame &&(!PhoneCallManager.IsCallActive))
{
//do something
}
if (PhoneCallManager.IsCallIncoming)
{
callCame = true;
}
}

something like this ? i need a little Assistance.

_taskCompletionToken = _deviceUseBackgroundTaskRegistration->Completed::add(
ref new BackgroundTaskCompletedEventHandler(
this, &Scenario1_DeviceUse::OnBackgroundTaskCompleted));

Solution

  • I have convert above code csharp code to c++ like following.

    PhoneCallManager::CallStateChanged += ref new Windows::Foundation::EventHandler<Platform::Object^>(this, &App8::MainPage::OnCallStateChanged);
    bool callCame;
    void App8::MainPage::OnCallStateChanged(Platform::Object^ sender, Platform::Object^ args)
    {
        if (callCame && (!PhoneCallManager::IsCallActive))
        {
            //do something
        }
        if (PhoneCallManager::IsCallIncoming)
        {
            callCame = true;
        }
    }