发送短信:

String body="this is sms demo";

Intent mmsintent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("smsto", number, null));

mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_BODY, body);

mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_COMPOSE_MODE, true);

mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_EXIT_ON_SENT, true); startActivity(mmsintent);

发送彩信:

StringBuilder sb = new StringBuilder();

sb.append("file://");

sb.append(fd.getAbsoluteFile());

Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mmsto", number, null));

// Below extra datas are all optional.

intent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_SUBJECT, subject);

intent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_BODY, body);

intent.putExtra(Messaging.KEY_ACTION_SENDTO_CONTENT_URI, sb.toString());

intent.putExtra(Messaging.KEY_ACTION_SENDTO_COMPOSE_MODE, composeMode);

intent.putExtra(Messaging.KEY_ACTION_SENDTO_EXIT_ON_SENT, exitOnSent);

startActivity(intent);

广播监听短信并显示内容:

AndroidManifest.xml中添加

再写一个广播监听

public class receive extends BroadcastReceiver

{

String receiveMsg = "";

public void onReceive(Context context, Intent intent)

{

SmsMessage[] msg= null;

if (intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED"))

{

//StringBuilder buf = new StringBuilder();

Bundle bundle = intent.getExtras();

if (bundle != null) {

Object[] pdusObj = (Object[]) bundle.get("pdus");

msg= new SmsMessage[pdusObj.length];

for (int i = 0; i

msg[i] = SmsMessage.createFromPdu ((byte[]) pdusObj[i]);

}

for(int i = 0; i < msg.length; i++)

{

String msgTxt = msg[i].getMessageBody();

if (msgTxt.equals("Testing!"))

{

Toast.makeText(context, "success!", Toast.LENGTH_LONG).show();

return;

}

else

{

Toast.makeText(context, msgTxt, Toast.LENGTH_LONG).show();

return;

}

}

return;

}

}

android 发送彩信监听,在Android中发送短信和彩信,监听短信并显示相关推荐

  1. android消息发送字符串,android - 从Android客户端通过HTTP在HL7消息中发送base64字符串时遇到错误 - 堆栈内存溢出...

    我正在android客户端(API 17)中使用HL7消息,并使用Hapi库生成和解析HL7消息.当我传输小的字符串值时,该消息工作正常. 但是我必须通过Http将图像发送到HL7服务器,为此,我正在 ...

  2. android 百度地图切换城市地图,android百度地图:卫星地图普通地图交通地图切换...

    在基础地图模式上,增加了普通图和卫星图的切换,以及是否增加交通图的图层. public class LayersDemo extends Activity { /** * MapView 是地图主控件 ...

  3. ASP.NET 2.0中发送电子邮件

    ASP.NET 2.0中发送电子邮件 ASP.NET 2.0 中发送电子邮件变得非常简单.发送电子邮件的类库主要在命名空间System.Net.Mail中,在这个命名空间中有两个核心类是:       ...

  4. android 实现自定义监听接口,Android在自定义类中实现自定义监听器方式

    Android在自定义类中实现自定义监听器方式 发布时间:2020-08-31 06:19:39 来源:脚本之家 阅读:203 作者:Simon_Qi 监听器可以说是Android开发中最常用的东西之 ...

  5. android inputmethodmanager 不自动弹出,Android中软键盘InputMethodManager的弹出和隐藏,以及显示和隐藏的监听...

    1.首先设置软键盘的弹出模式,设置在初始化View的前面 @Override protected void onCreate(Bundle savedInstanceState) { this.req ...

  6. 安卓短信功能全解:调用系统短信功能发送短信、彩信,使用SmsManager发送短信,并监听发送短信的投递情况,使用广播接收器监听接收的短信。

    全栈工程师开发手册 (作者:栾鹏) 安卓教程全解 安卓短信功能全解:调用系统短信功能发送短信.彩信,使用SmsManager发送短信,并监听发送短信的投递情况,使用广播接收器监听接收的短信. 首先需要 ...

  7. Android中发送和接收短信

    在做Android开发中经常要用到短信的发送和短信的接收,调用Android提供的api实现起来很简单,今天要用到这个功能研究了一下顺便写下来加强一下记忆. 1.首先创建一个Android Proje ...

  8. Android笔记(三十一)Android中线程之间的通信(三)子线程给主线程发送消息...

    先看简单示例:点击按钮,2s之后,TextView改变内容. package cn.lixyz.handlertest;import android.app.Activity; import andr ...

  9. android通知栏的点击事件,Android监听消息通知栏点击事件

    Android监听消息通知栏点击事件 使用BroadCastReceiver 1 新建一个NotificationClickReceiver 类,并且在清单文件中注册!! public class N ...

最新文章

  1. SQL Server 2008 认证之路
  2. java dozer 深度_java – Dozer深度映射设置为Set
  3. Win32 多线程学习总结
  4. 社区医学的研究方法:调查、流行病学研究、方案评估、临床试验Research Methods in Community Medicine: Surveys, Epidemiological Resear
  5. 添加多个tomcat服务目录
  6. JavaScript文本特效实例小结【3个示例】
  7. 管理系统页面脚手架(一)
  8. Java中对象的直接赋值、浅拷贝及深拷贝的理解和应用场景及其实现方式
  9. ansi 软件测试,VB中的Unicode和Ansi格式
  10. python中ipo是什么意思呢_ipo是什么意思呢?ipo是不是就是上市呢?
  11. html希腊字符,希腊字母
  12. SA299学习笔记 第一章 描述接口配置(3)
  13. 2022年3月15日黑马第三天
  14. matlab摩托车刹车问题,摩托车刹车系统的这些知识,你了解过吗?
  15. 电脑设置了从睡眠中唤醒需要密码却没生效(已解决)
  16. HTML最给力的入门教程
  17. Fedora 安装字体
  18. 【干货】超强整理19个辅助制作H5的工具/网站
  19. hdu5643 King's Game (BC#75D)
  20. MFC_改变窗口大小,随着鼠标的拖动改变

热门文章

  1. 西北乱跑娃 --- python类方法重写
  2. bat脚本案例:实现炫酷的文字logo
  3. ai人工智能将替代人类_只有人工智能才能将我们从假货世界中拯救出来(人工智能也在创造世界)...
  4. Cesium出现Unknown crs name: urn:ogc:def:crs:EPSG:xxxx
  5. U盘不识别,磁盘管理器显示无媒体
  6. Ansoft_ansys_hfss_12.1.rar
  7. sketchup转stl_skp怎么转化成stl,我用sketchUp建了模想3D打印
  8. 信息奥赛一本通1312:【例3.4】昆虫繁殖
  9. 音频增强工具:DeskFX Plus Mac
  10. 【YMGJ】很激动的一刻:将时间显示出来