Android短信开发 发送短信 ' 高通源码 '(发送成功或发送失败改变状态)
发布日期:2021-06-30 21:23:16
浏览次数:2
分类:技术文章
本文共 4077 字,大约阅读时间需要 13 分钟。
短信普通发送过程
在执行完 SmsSindleRecipientSender.java 类会重新开启广播 SmsReceiver.java重新启动服务SmsReceiverService.java
如果发送成功传入一个Action "com.android.mms.transaction.MESSAGE_SENT" ,
执行完SmsSindleRecipientSender.java类后执行SmsReceiverService.java里面handleSmsSend(Intent intent,int error)
private void handleSmsSent(Intent intent, int error) {//发送成功更改状态 Uri uri = intent.getData(); int resultCode = intent.getIntExtra("result", 0);//发送状态是否发送成功 boolean sendNextMsg = intent.getBooleanExtra(EXTRA_MESSAGE_SENT_SEND_NEXT, false); int subId = intent.getIntExtra(ConstantsWrapper.Phone.SUBSCRIPTION_KEY, SubscriptionManager.getDefaultSmsSubscriptionId()); mSending.put(subId, false); LogTag.debugD("handleSmsSent uri: " + uri + " sendNextMsg: " + sendNextMsg + " resultCode: " + resultCode + " = " + translateResultCode(resultCode) + " error: " + error); if (resultCode == Activity.RESULT_OK) { if (sendNextMsg) { Log.v(TAG, "handleSmsSent: move message to sent folder uri: " + uri); if (!TelephonyWrapper.Sms.moveMessageToFolder(this, uri, Sms.MESSAGE_TYPE_SENT, error)) { Log.e(TAG, "handleSmsSent: failed to move message " + uri + " to sent folder"); } sendFirstQueuedMessage(subId); } // Update the notification for failed messages since they may be deleted. MessagingNotification.nonBlockingUpdateSendFailedNotification(this); } else if ((resultCode == SmsManager.RESULT_ERROR_RADIO_OFF) || //发送失败 (resultCode == SmsManager.RESULT_ERROR_NO_SERVICE)) { LogTag.debugD("handleSmsSent: no service, queuing message w/ uri: " + uri); // We got an error with no service or no radio. Register for state changes so // when the status of the connection/radio changes, we can try to send the // queued up messages. registerForServiceStateChanges(); // We couldn't send the message, put in the queue to retry later. TelephonyWrapper.Sms.moveMessageToFolder(this, uri, Sms.MESSAGE_TYPE_QUEUED, error); mToastHandler.post(new Runnable() { public void run() {//拔卡发送 liwangjiang Toast.makeText(SmsReceiverService.this, getString(R.string.message_queued), Toast.LENGTH_SHORT).show(); //拔卡时更改状态 TelephonyWrapper.Sms.moveMessageToFolder(getApplicationContext(), uri, Sms.MESSAGE_TYPE_FAILED, error);//改变状态 } }); } else if (resultCode == SmsManagerWrapper.RESULT_ERROR_FDN_CHECK_FAILURE) { messageFailedToSend(uri, resultCode); mToastHandler.post(new Runnable() { public void run() { Toast.makeText(SmsReceiverService.this, getString(R.string.fdn_check_failure), Toast.LENGTH_SHORT).show(); } }); if (sendNextMsg) { sendFirstQueuedMessage(subId); } } else { messageFailedToSend(uri, error); if (sendNextMsg) { sendFirstQueuedMessage(subId); //关闭广播 } } }
改变状态的代码
TelephonyWrapper.Sms.moveMessageToFolder(getApplicationContext(), uri, Sms.MESSAGE_TYPE_FAILED, error);
发送状态
/** Message type: all messages. */ public static final int MESSAGE_TYPE_ALL = 0; /** Message type: inbox. */ public static final int MESSAGE_TYPE_INBOX = 1; /** Message type: sent messages. */ public static final int MESSAGE_TYPE_SENT = 2; /** Message type: drafts. */ public static final int MESSAGE_TYPE_DRAFT = 3; /** Message type: outbox. */ public static final int MESSAGE_TYPE_OUTBOX = 4; /** Message type: failed outgoing message. */ public static final int MESSAGE_TYPE_FAILED = 5; /** Message type: queued to send later. */ public static final int MESSAGE_TYPE_QUEUED = 6;
转载地址:https://liwangjiang.blog.csdn.net/article/details/88672620 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
表示我来过!
[***.240.166.169]2024年04月09日 15时16分32秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
关于greater<int>以及类模板的一些理解
2019-04-30
对于时间复杂度的通俗理解
2019-04-30
如何输入多组数据并输出每组数据的和?
2019-04-30
基于CentOS 7的Linux常用命令行命令
2019-04-30
行阶梯型矩阵
2019-04-30
临界资源与临界区
2019-04-30
matlab中uint8,double,im2double和im2uint8的区别
2019-04-30
数字图像处理总复习
2019-04-30
图像去噪(包含修正的阿尔法均值滤波及通用滤波方法代码)
2019-04-30
SVM进行人脸检测
2019-04-30
C++学习笔记
2019-04-30
图像处理学习笔记
2019-04-30
Machine Learning Onramp on MATLAB 学习笔记
2019-04-30
Machine Learning with MATLAB 1.1 to 2.2
2019-04-30
Learning DSP with MATLAB
2019-04-30
用MATLAB实现m序列的生成(MATLAB 2021a适用)
2019-04-30
MATLAB函数备忘(定期更新)
2019-04-30
13行MATLAB代码实现网络爬虫 爬取NASA画廊星图
2019-04-30
MATLAB指定路径保存图片方法
2019-04-30
Python一键获取微信推送封面图
2019-04-30