Android之短信发送器
16lz
2021-12-04
效果图:
界面布局:
[html] view plain copy- <?xmlversion="1.0"encoding="utf-8"?>
- <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
- <!--显示控件-->
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/moblie"
- />
- <!--文本框按钮-->
- <EditText
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:id="@+id/moblie"
- />
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/content"
- />
- <EditText
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:minLines="3"
- android:id="@+id/content"
- />
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/button"
- android:id="@+id/button"
- />
- </LinearLayout>
接着是资源文件strings.xml
添加短信服务权限:
[html] view plain copy- <?xmlversion="1.0"encoding="utf-8"?>
- <manifestxmlns:android="http://schemas.android.com/apk/res/android"
- package="cn.itcast.action"
- android:versionCode="1"
- android:versionName="1.0">
- 略....
- <uses-sdkandroid:minSdkVersion="8"/>
- <!--短信服务权限-->
- <uses-permissionandroid:name="android.permission.SEND_SMS"/>
- </manifest>
---------------------------------------------------------------------------------------
smsManager.sendTextMessage(destinationAddress, scAddress, text, sentIntent, deliveryIntent)
如果不用,后面两个可以为null
--destinationAddress 目标电话号码,收报地址
-- ScAddress通讯录 服务商的短信中心号码(例如中国移动的短信中心号码),测试可以不填。
-- sentIntent:发送(短信) -->中国移动 --> 中国移动发送失败 --> 返回发送成功或失败信号(广播出去) --> 后续处理 即,这个意图包装了短信发送状态的信息
-- deliveryIntent: 广播(短信)接收器 即:这个意图包装了短信是否被对方收到的状态信息(供应商已经发送成功,但是对方没有收到)。//delivery 交付
更多相关文章
- android 里使用Socket进行发送消息案例
- Android中短信拦截解决方案
- android打电话和发短信
- Android中短信拦截解决方案
- android邮件发送几种方式
- Android(安卓)下面的一些命令
- Android实习笔记----调用拨号器,邮件短信和Google 地图
- android 局域网聊天工具(可发送文字/语音)
- Android百度地图导航的那些坑