Programatically send SMS (Not getting delivery sta

2019-09-06 06:14发布

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条回答
混吃等死
2楼-- · 2019-09-06 06:30

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.

查看更多
登录 后发表回答