效果图:

界面布局:

[html] view plain copy
  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
  3. android:orientation="vertical"
  4. android:layout_width="fill_parent"
  5. android:layout_height="fill_parent"
  6. >
  7. <!--显示控件-->
  8. <TextView
  9. android:layout_width="fill_parent"
  10. android:layout_height="wrap_content"
  11. android:text="@string/moblie"
  12. />
  13. <!--文本框按钮-->
  14. <EditText
  15. android:layout_width="fill_parent"
  16. android:layout_height="wrap_content"
  17. android:id="@+id/moblie"
  18. />
  19. <TextView
  20. android:layout_width="fill_parent"
  21. android:layout_height="wrap_content"
  22. android:text="@string/content"
  23. />
  24. <EditText
  25. android:layout_width="fill_parent"
  26. android:layout_height="wrap_content"
  27. android:minLines="3"
  28. android:id="@+id/content"
  29. />
  30. <Button
  31. android:layout_width="wrap_content"
  32. android:layout_height="wrap_content"
  33. android:text="@string/button"
  34. android:id="@+id/button"
  35. />
  36. </LinearLayout>

接着是资源文件strings.xml



Activity





添加短信服务权限:

[html] view plain copy
  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <manifestxmlns:android="http://schemas.android.com/apk/res/android"
  3. package="cn.itcast.action"
  4. android:versionCode="1"
  5. android:versionName="1.0">
  6. 略....
  7. <uses-sdkandroid:minSdkVersion="8"/>
  8. <!--短信服务权限-->
  9. <uses-permissionandroid:name="android.permission.SEND_SMS"/>
  10. </manifest>

---------------------------------------------------------------------------------------

smsManager.sendTextMessage(destinationAddress, scAddress, text, sentIntent, deliveryIntent)

如果不用,后面两个可以为null

--destinationAddress 目标电话号码,收报地址

-- ScAddress通讯录 服务商的短信中心号码(例如中国移动的短信中心号码),测试可以不填。

-- sentIntent:发送(短信) -->中国移动 --> 中国移动发送失败 --> 返回发送成功或失败信号(广播出去) --> 后续处理 即,这个意图包装了短信发送状态的信息

-- deliveryIntent: 广播(短信)接收器 即:这个意图包装了短信是否被对方收到的状态信息(供应商已经发送成功,但是对方没有收到)。//delivery 交付



更多相关文章

  1. android 里使用Socket进行发送消息案例
  2. Android中短信拦截解决方案
  3. android打电话和发短信
  4. Android中短信拦截解决方案
  5. android邮件发送几种方式
  6. Android(安卓)下面的一些命令
  7. Android实习笔记----调用拨号器,邮件短信和Google 地图
  8. android 局域网聊天工具(可发送文字/语音)
  9. Android百度地图导航的那些坑

随机推荐

  1. android常用控件
  2. 如何制作Android手电筒程序
  3. Android下进行 Facebook 分享
  4. Android(安卓)图片缩放实例详解
  5. 横向 纵向结合的ScrollView
  6. android用于打开各种文件的intent
  7. Android圆角图片封装类(直接使用)
  8. android旋转图片
  9. android获取图库图片并返回
  10. Android查询SIM卡所有信息