监听短信接收者笔记
来源:互联网 发布:全球中文地图导航软件 编辑:程序博客网 时间:2024/05/16 17:38
第一步:在清单文件中注释receiver name指定要继承的broadcastReceiver <intent-filter priority设定短信接收的优先级><action name指定sms_received记得加primission权限read_sms与receive_sms
第二步:新建一个类继承boardcasereceiver,在onreceive方法当中
通过 Object[] obj = (Object[])intent.getExtra().get("pdus");拿到一组短信流
for(int i = 0 ; i < obj.length; i++){
SmsMessage sm = SmsMessage.createFromPdu((byte[])obj[i]);//注意 smsmessage别引入gsm包下的
//下面就可以拿到短信的originalAddress与messagebody了
//通过abortBroadcastReceiver结束掉这个广播了
//下面是发送短信,也在这里写一下吧
/**
*smsmanager sms = smsmanager.getdefault();//拿到实例,记得别引入gsm的
*sms.sendtextmessage();//以下为参数说明
- Parameters:
- destinationAddress the address to send the message to
- scAddress is the service center address or null to use the current default SMSC
- text the body of the message to send
- sentIntent if not NULL this
PendingIntent
is broadcast when the message is successfully sent, or failed. The result code will beActivity.RESULT_OK
for success, or one of these errors:RESULT_ERROR_GENERIC_FAILURE
RESULT_ERROR_RADIO_OFF
RESULT_ERROR_NULL_PDU
ForRESULT_ERROR_GENERIC_FAILURE
the sentIntent may include the extra "errorCode" containing a radio technology specific value, generally only useful for troubleshooting.
The per-application based SMS control checks sentIntent. If sentIntent is NULL the caller will be checked against all unknown applications, which cause smaller number of SMS to be sent in checking period. - deliveryIntent if not NULL this
PendingIntent
is broadcast when the message is delivered to the recipient. The raw pdu of the status report is in the extended data ("pdu").
*/
}
+++++++++++++++++++++++++++++++++++++++++++++++
自定义广播
1需要在清单文件当中设置receiver,name指定继承boardcastreceiver的类了 这个没什么好说的
2<intent-filter><action name="com.tiger.xx"></action></intent-filter>//这里不需要指定优先级,action中的name是自定义的
3在activity当中通过按钮来发送一个有序广播 Intent intent = new Intent(); intent.setAction("com.tiger.xx"); sendOrderBroadcastReceiver();
以下是参数说明
- Parameters:
- intent The Intent to broadcast; all receivers matching this Intent will receive the broadcast.
- receiverPermission String naming a permissions that a receiver must hold in order to receive your broadcast. If null, no permission is required.
- resultReceiver Your own BroadcastReceiver to treat as the final receiver of the broadcast.
- scheduler A custom Handler with which to schedule the resultReceiver callback; if null it will be scheduled in the Context's main thread.
- initialCode An initial value for the result code. Often Activity.RESULT_OK.
- initialData An initial value for the result data. Often null.
- initialExtras An initial value for the result extras. Often null.
- 监听短信接收者笔记
- android基础笔记——广播接收者,实现短信监听
- 使用广播接收者监听短信
- Android-广播接收者;短信监听
- android广播接收者实例_短信监听
- 广播接收者 作用:短信监听器, 转播电话,重启监听
- 广播接收者之监听短信并获取内容
- Android短信的发送和广播接收者实现短信的监听
- Android短信的发送和广播接收者实现短信的监听
- android广播和短信广播详解----使用广播接收者监听短信
- 广播接收者拦截短信
- 短信广播接收者
- 短信广播接收者(拦截)
- 短信广播接收者
- 短信的广播接收者
- android 使用广播接收者监听短信和拦截外拨电话
- android 使用广播接收者监听短信和拦截外拨电话
- android 使用广播接收者监听短信和拦截外拨电话
- php+MYSQL+APACHE环境搭建
- leetcode-----Single Number II
- Android LayoutInflater原理分析,带你一步步深入了解View(一)
- 尽管会摔破更多的茶壶
- 最近运营了一个名为“聚返网”的返利网,优化了一个多月效果不佳啊。
- 监听短信接收者笔记
- Nutch学习与安装
- POSIX详解pthread_mutex_lock
- 音视频通讯开发的日志文件
- 2016 香港 最快 最稳定 的 dns 地址
- EXTJS4.0 页面间传值 监听事件的使用 值处理
- hdu-1495
- 音视频通讯开发的日志文件
- appfuse 访问很慢