public class MyBroad extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {

private String actions = intent.getAction();
if (actions.equals("android.provider.Telephony.SMS_RECEIVED")) {
  //收到短信了
  Bundle bundle = intent.getExtras();
  Object[] pdus = (Object[]) bundle.get("pdus");
  SmsMessage[] messages = new SmsMessage[pdus.length];
  for (int i = ; i < messages.length; i++) {
     SmsMessage ms = SmsMessage.createFromPdu((byte[])pdus[i]);
    String from = ms.getDisplayOriginatingAddress().toString();
    String content = ms.getMessageBody().toString();
    SimpleDateFormat sf= new SimpleDateFormat("yyyy-MM-DD HH:mm:ss");
    String time = sf.format(ms.getTimestampMillis());
    String result = "time:"+time+" from:"+from+" content"+content;
    Toast.makeText(context,result,Toast.LENGTH_SHORT).show();

  }
  abortBroadcast();

}
}
}

权限:<uses-permission android:name="android.permission.RECEIVE_SMS"/>

清单配置

<receiver android:name=".MyBroad" >
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>

打电话:

<uses-permission android:name="android.permission.CALL_PHONE"/>

  Intent(Intent.ACTION_CALL,Uri.parse("tel:1888888"));

其它广播ACTION

开机启动广播权限 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
开机启动<action android:name="android.intent.action.BOOT_COMPLETED"/>
关机 <action android:name="android.intent.action.ACTION_SHUTDOWN"/>
低电量 <action android:name="android.intent.action.BATTERY_LOW"/>
 

  

												

android 广播 接收短信的更多相关文章

  1. android学习十四(android的接收短信)

    收发短信是每一个手机主要的操作,android手机当然也能够接收短信了. android系统提供了一系列的API,使得我们能够在自己的应用程序里接收和发送短信. 事实上接收短信主要是利用我们前面学过的 ...

  2. Android使用BroadCastRecevier广播实现接收短信,并利用Toast弹出显示内容

    在上一篇文章 Android简单实现BroadCastReceiver广播机制 中简单的实现了一个广播机制,这里利用BroadCarstRecevier实现一个接收短信并显示内容的案例,当然至于接收到 ...

  3. android接收短信——framework处理流程(android 5.1)

    modem层不懂,所以直接从RIL.java开始.以电信卡接收短信为例 modem通知RIL.java中的 RILReceiver处理接收信息 class RILReceiver implements ...

  4. Android接收短信

    Android收到短信时会广播android.provider.Telephony.SMS_RECEIVED消息,因此只要定义一个Receiver,收听该消息,就能接收短信. <receiver ...

  5. Android 监听短信(同时监听广播和数据库)

    暗扣,强烈谴责这种侵害用户利益的行为... 下面给大家介绍Android暗扣原理.......  Android4.4以下的系统玩游戏就要小心了哈 暗扣方式之一:短信订购,即监听--------拦截- ...

  6. Android 接收短信

    启动程序时启动一个service,在service里注册接收短信的广播,当手机收到短信里,打印出短信内容跟电话号码. package com.lmy.SmsListener; import andro ...

  7. android基础---->发送和接收短信

    收发短信应该是每个手机最基本的功能之一了,即使是许多年前的老手机也都会具备这项功能,而Android 作为出色的智能手机操作系统,自然也少不了在这方面的支持.今天我们开始自己创建一个简单的发送和接收短 ...

  8. android自动填写短信验证码

    广播类 package com.examp.azuoyoutong.listner; import java.util.regex.Matcher;import java.util.regex.Pat ...

  9. Android通讯:短信

    Android通讯之短信功能实现: 使用android.telephony.SmsManager对象,可以发送短信和彩信.// 构造回调函数,短信发送结束后,会发出对应的Intent请求Intent ...

随机推荐

  1. python try 异常处理 史上最全

    在程序出现bug时一般不会将错误信息显示给用户,而是现实一个提示的页面,通俗来说就是不让用户看见大黄页!!! 有时候我们写程序的时候,会出现一些错误或异常,导致程序终止. 为了处理异常,我们使用try ...

  2. English trip V1 - 20.Look at me 看着我 Teacher:Solo Key: 声调(英语默认就声调[rising]和降调[falling]两种)

    In this lesson you will learn to describe a person. 课上内容(Lesson) appearance  -> ap pea ran ce  外貌 ...

  3. Lab 1-4

    Analyze the file Lab01-04.exe. Questions and Short Answers Upload the Lab01-04.exe file to http://ww ...

  4. Vue音乐项目笔记(五)

    1.搜索列表的点击删除.删除全部的交互事件 https://blog.csdn.net/weixin_40814356/article/details/80496097 seach组件中放search ...

  5. SpringBoot项目Shiro的实现(一)

    一.Shiro的简单介绍 Shiro是Apache下的一个开源项目,我们称之谓Apache Shiro,它是一个易用与Java项目的安全框架,提供了认证.授权.加密.会话管理,与Spring Secu ...

  6. SpringMVC的底层实现

    SpringMVC的底层实现流程: SpringMVC的核心是DispatchServlet,它负责接收HTTP的请求和协调SpringMVC中各个组件来完成请求处理的任务,一个请求被截获后,Disp ...

  7. Git将本地项目上传到GitHub

    本文转载于:https://segmentfault.com/a/1190000011909294 https://www.cnblogs.com/cxk1995/p/5800196.html 我们使 ...

  8. ECharts饼状图添加事件

    和柱状图添加事件没有区别,详情如下: <!DOCTYPE html> <html> <head> <meta http-equiv="Content ...

  9. git如何merge github forked repository里的代码更新?(转)

    参考内容:git如何merge github forked repository里的代码更新? [refer to ]http://www.haojii.com/2011/08/how-to-git- ...

  10. Tips about Troubleshooting RAC

    Installation Log Filessoftware installation log files inside the logs directory of Oracle central in ...