Yanıt Unable to get default SMS device

  • 09 Kasım 2011 Çarşamba 09:32
     
      Kod İçerir

    Hi,

    when trying to call SmsDevice.GetDefault() I sometimes get an unexpected COM exception. Going back to documentation I read that the async operation should ship around this:

    "Because the device might be busy, the operation executes asynchronously. The asynchronous operation object returns immediately."

     

    I rewrote the code to access the device to use the async operation, but in no case the operation ever returned. Even worse, it looks as if the async operation doesn't ever execute. Here is my piece of code:

     

            public async void ReadMessagesAsync()
            {
                try
                {
                    System.Diagnostics.Debug.WriteLine("Getting device"); 
                    ISmsDevice device = await SmsDevice.GetDefaultAsync();
                    if (device == null)
                    {
                        System.Diagnostics.Debug.WriteLine("No device");
                        return;
                    }
                    System.Diagnostics.Debug.WriteLine("Reading messages");
                    IReadOnlyList<ISmsMessage> messages = await device.MessageStore.GetMessagesAsync(SmsMessageFilter.All);
                    foreach (SmsBinaryMessage message in messages)
                    {
                        SmsTextMessage smsText = SmsTextMessage.FromBinaryMessage(message);
                        System.Diagnostics.Debug.WriteLine(string.Format("From: {0}\r\n{1}", smsText.From, smsText.Body));
                    }
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine(e);
                }
            }

    It does never continue after hitting:

     

    ISmsDevice device = await SmsDevice.GetDefaultAsync();

     

    Can somebody help?

     

    Best regards, Michael



Tüm Yanıtlar

  • 11 Kasım 2011 Cuma 17:48
    Moderatör
     
     

    Hi Michael,

    What is the specific COM exception you are receiving from GetDefault()?

    Do you see the same behavior with the "Sms Send/Receive" sample?

     

    http://code.msdn.microsoft.com/windowsapps/Sms-SendReceive-fa02e55e

     

    thanks

    Frank

  • 05 Nisan 2012 Perşembe 17:18
     
     

    I'm getting exactly the same problems.

    I get the COM exception anytime my 3G USB stick is missing (which is easily remedied by plugging it in)

    Based on the sample code, I can call GetMessageAsync (Note no plural) and retrieve a message at a time, but not filtered to Unread/Read/etc, but if you call GetMessagesAsync (Note messageS) then it never returns. You will note that GetMessageS is not used in the sample


    • Düzenleyen AlSki.Net 05 Nisan 2012 Perşembe 17:19
    •  
  • 11 Nisan 2012 Çarşamba 13:45
     
     

    I can able to send and receive SMS and retrieve the messages using the GetMessageAsync call by passing the message id.

    But When I am trying to use GetMessagesAysnc, I am seeing an error. 

    var ReadAllMessages = smsdevice.MessageStore.GetMessagesAsync(SmsMessageFilter.All);

    ReadAllMessages Errorcode "Message = "Number of parameters specified does not match the expected number."

    Rest of the APIs are working, I am seeing problems only with GetMessagesAysnc function.

  • 06 Haziran 2012 Çarşamba 04:51
    Moderatör
     
     Yanıt

    This functionality is only available to mobile operator apps and Metro style apps given privileged access by mobile network operators.

    Best Wishes - Eric

  • 29 Temmuz 2012 Pazar 15:38
     
     

    Was this issue ever resolved? I have the same problem - getMessageAsync from returns "The parameter is incorrect" from a js app. (and I do have privileged access as I'm developing for a mobile network operator)

    Mike


    • Düzenleyen MikeHowey 30 Temmuz 2012 Pazartesi 10:19
    •  
  • 05 Eylül 2012 Çarşamba 09:09
     
     

    i have authored the device metadata for my 3G datacard, and filled the SMS sample app information in the wizzard. After that, i debuged the SMS sample code, but when it hit the SmsDevice::GetDefaultAsync(), the exception HRESULT:0x80070005 always come out? does someone meet the same issue?

  • 24 Eylül 2012 Pazartesi 13:58
     
     
    access denied. when i turn off the text message permission, it will show the 0X80070005 E_ACCESSDENIED error code
  • 25 Eylül 2012 Salı 20:02
    Moderatör
     
     Yanıt

    This functionality is only available to mobile operator apps and Windows Store apps given privileged access by mobile network operators, mobile broadband adapter IHV, or OEM. For more information, see Mobile Broadband: Windows Store device apps.

    Best Wishes - Eric

  • 31 Ekim 2012 Çarşamba 08:29
     
     
    The computer must be set to the TEST MODE.