Android中的短信发送报告

Android中的短信发送报告,第1张

概述我想收到短信发送报告我正在尝试很多例子但是,一个流程没有显示发送报告,如果我的余额为0,当我的代码中的短信发送不显示短信发送报告失败,否则显示报告,如没有服务等..我想要当我的余额为0时,查找短信发送失败的送达报告. 帮我任何代码! 提前致谢! BroadcastReceiver sendBroadcastReceiver = new SentReceiver(); BroadcastRe 我想收到短信发送报告我正在尝试很多例子但是,一个流程没有显示发送报告,如果我的余额为0,当我的代码中的短信发送不显示短信发送报告失败,否则显示报告,如没有服务等..我想要当我的余额为0时,查找短信发送失败的送达报告.

帮我任何代码!

提前致谢!

解决方法
broadcastReceiver sendbroadcastReceiver = new SentReceiver();    broadcastReceiver deliverybroadcastRecIEver = new DeliverReceiver();;    @OverrIDe    protected voID onPause() {        // Todo auto-generated method stub        super.onPause();        try {            unregisterReceiver(sendbroadcastReceiver);            unregisterReceiver(deliverybroadcastRecIEver);        } catch (Exception e) {            // Todo auto-generated catch block            e.printstacktrace();        }    }@OverrIDeprotected voID onDestroy() {    // Todo auto-generated method stub    super.onDestroy();    try {        unregisterReceiver(sendbroadcastReceiver);        unregisterReceiver(deliverybroadcastRecIEver);    } catch (Exception e) {        // Todo auto-generated catch block        e.printstacktrace();    }}    send_sms.setonClickListener(new OnClickListener() {            @OverrIDe            public voID onClick(VIEw v) {                // Todo auto-generated method stub                if (textVIEw.getText().toString().equals("")                        | textVIEw.getText().toString().equals(null)) {                    Toast.makeText(SendSMS.this,enter_ph_no,Toast.LENGTH_LONG)                            .show();                } else {                        sendSMS(textVIEw.getText().toString(),"sms_content");                        finish();                }            }        });private voID sendSMS(String phoneNumber,String message) {        String SENT = "SMS_SENT";        String DEliVERED = "SMS_DEliVERED";        PendingIntent sentPI = PendingIntent.getbroadcast(this,new Intent(                SENT),0);        PendingIntent deliveredPI = PendingIntent.getbroadcast(this,new Intent(DEliVERED),0);        registerReceiver(sendbroadcastReceiver,new IntentFilter(SENT));        registerReceiver(deliverybroadcastRecIEver,new IntentFilter(DEliVERED));        SmsManager sms = SmsManager.getDefault();        sms.sendTextMessage(phoneNumber,null,message,sentPI,deliveredPI);    }    class DeliverReceiver extends broadcastReceiver {        @OverrIDe        public voID onReceive(Context context,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;            }        }    }    class SentReceiver extends broadcastReceiver {        @OverrIDe        public voID onReceive(Context context,sms_sent,Toast.LENGTH_SHORT)                        .show();                startActivity(new Intent(SendSMS.this,ChooSEOption.class));                overrIDePendingTransition(R.anim.animation,R.anim.animation2);                break;            case SmsManager.RESulT_ERROR_GENERIC_FAILURE:                Toast.makeText(getBaseContext(),"Generic failure",Toast.LENGTH_SHORT).show();                break;            case SmsManager.RESulT_ERROR_NO_SERVICE:                Toast.makeText(getBaseContext(),"No service",Toast.LENGTH_SHORT).show();                break;            case SmsManager.RESulT_ERROR_NulL_PDU:                Toast.makeText(getBaseContext(),"Null PDU",Toast.LENGTH_SHORT)                        .show();                break;            case SmsManager.RESulT_ERROR_RAdio_OFF:                Toast.makeText(getBaseContext(),"Radio off",Toast.LENGTH_SHORT).show();                break;            }        }    }
总结

以上是内存溢出为你收集整理的Android中的短信发送报告全部内容,希望文章能够帮你解决Android中的短信发送报告所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1121470.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存