Click here to Skip to main content
15,850,299 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(PhoneLineTransportDevice.GetDeviceSelector(PhoneLineTransport.Bluetooth));
for (int i = 0; i < devices.Count; i++)
{
    Console.WriteLine(i + "#:    " + devices[i].Name + "    " + devices[i].Id);
}

select:
Console.WriteLine("Please input device id to select");

if (int.TryParse(Console.ReadLine(), out int s))
{
    if (s < 0 || s > devices.Count)
    {
        goto select;
    }
    Console.WriteLine("Selected: " + devices[s].Name + "    " + devices[s].Id);
}
else
{
    goto select;
}

var PDevice = PhoneLineTransportDevice.FromId(devices[s].Id);
var result = await PDevice.RequestAccessAsync();
if (!PDevice.IsRegistered())
{
    PDevice.RegisterApp();
}
var flag = await PDevice.ConnectAsync();
if (flag)
{
    Console.WriteLine("Connected");
}
else
{
    Console.WriteLine("Could not connect to PhoneLineDevice");
}
PhoneCallStore store = await PhoneCallManager.RequestStoreAsync();
PhoneLine pl = await PhoneLine.FromIdAsync(await store.GetDefaultLineAsync());
pl.DialWithOptions(new PhoneDialOptions { AudioEndpoint = PhoneAudioRoutingEndpoint.Bluetooth, Number = "18589846271" });

Console.ReadLine();
PDevice.UnregisterApp();


What I have tried:

in this code var result = await PDevice.RequestAccessAsync();
this is resulting in denied by system i dont know why
Posted
Updated 25-Apr-23 22:23pm
v2
Comments
Richard MacCutchan 26-Apr-23 3:48am    
It most likely means that you do not have the required permissions to get the device information. But your question lacks detail.

And your use of goto statements suggests you need to learn how to code a simple for loop.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900