Whether SIM card is available or not in windows phone universal project

家住魔仙堡 提交于 2019-12-11 06:58:43

问题


I'm creating winrt universal project for mobile and tablet.

I want to check:

In mobile application, I am sending a sms text to sms application like this.

var message = new ChatMessage();
message.Recipients.Add("9999");
message.Body = "R*" + voucherNo + "*" + accountNo + "*" + pin;
await ChatMessageManager.ShowComposeSmsMessageAsync(message);

I want to place a check above that whether user has inserted sim card or using mobile with out sim card. Well app is not crashing due to this so this is not a big issue if I couldn't place that check here (as I have already searched alot about it but got nothing so I'm assuming that it is not possible right not in winrt to check sim card availability), but a link of documentation/blog/SO question regarding this where it is mentioned that you can't check sim card availability would be helpful.

Thanks.


回答1:


bool simAvailable = false;
var device = await ChatMessageManager.GetTransportsAsync();
if (device != null && device.Count > 0)
{
    foreach (var item in device)
    {
        if (item.TransportFriendlyName != "No SIM")
        {
            simAvailable = true;
            break;
        }
    }
}

Just enter this code and Simavailable will be true if phone hase sim card.



来源:https://stackoverflow.com/questions/31177243/whether-sim-card-is-available-or-not-in-windows-phone-universal-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!