Programatically send SMS (Not getting delivery status) [duplicate]

不羁岁月 提交于 2019-12-25 05:22:01

问题


Possible Duplicate:
Programatically send SMS Android (Not receiving status)

I am using this code example word for word except for the fact that I changed

   import android.telephony.gsm.SmsManager;

to

   import android.telephony.SmsManager;

The SMS is sending fine however I am not getting the TOAST message that it was delivered (sent to the network). I am trying to integrate SMS into my application and this is important. I am sure this can be done because how else would the stock SMS app know when to stop displaying the "sending circle". The relevant code section is as follows:

    //---when the SMS has been delivered---
    registerReceiver(new BroadcastReceiver(){
        @Override
        public void onReceive(Context arg0, Intent arg1) {
            switch (getResultCode())
            {
                case Activity.RESULT_OK:
                    Toast.makeText(getBaseContext(), "SMS delivered", 
                            Toast.LENGTH_SHORT).show();
                    break;
                case Activity.RESULT_CANCELED:
                    Toast.makeText(getBaseContext(), "SMS not delivered", 
                            Toast.LENGTH_SHORT).show();
                    break;                        
            }
        }
    }, new IntentFilter(DELIVERED));        

I am using a Jelly Bean ROM but I believe I tested this same segment a while ago on Gingerbread and ICS with the same results. Has the API changed or is there an issue with the sample? I am testing on a Sasmsung GSIII if that helps. My old tests were on an Epic.


回答1:


Using a Toast to test can confuse things since depending on the situation the Toast notification may not be raised. Try changing it to a Log call or use a debugger to see if that part gets called at all.



来源:https://stackoverflow.com/questions/12701215/programatically-send-sms-not-getting-delivery-status

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