黑马Android:短信发送器
来源:互联网 发布:淘宝照片在哪拍 编辑:程序博客网 时间:2024/04/28 08:01
public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void send(View v){ //拿到用用户输入的号码和内容 EditText et_phone = (EditText) findViewById(R.id.et_phone); EditText et_content = (EditText) findViewById(R.id.et_content); String phone = et_phone.getText().toString(); String content = et_content.getText().toString(); //1.获取短信管理器 SmsManager sm = SmsManager.getDefault(); //2.切割短信,把长短信分成若干个小短信 ArrayList<String> smss = sm.divideMessage(content); //3.for循环把集合中所有短信全部发送出去 for(String string : smss){ sm.sendTextMessage(phone, null, string, null, null); } }}
<!--添加权限--> <uses-permission android:name="android.permission.SEND_SMS"/>
<!--布局文件--><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="indi.cc.smssender.MainActivity" android:orientation="vertical" > <EditText android:id="@+id/et_phone" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="phone" android:hint="请输入对方号码" /> <EditText android:id="@+id/et_content" android:layout_width="match_parent" android:layout_height="wrap_content" android:lines="5" android:hint="请输入短信内容" android:gravity="top" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="发送" android:onClick="send" /></LinearLayout>
界面显示
0 0
- 黑马Android:短信发送器
- Android短信发送器
- android 短信发送器
- android短信发送器
- Android短信发送器
- android短信发送器
- android 短信发送器
- Android短信发送器
- Android -- 短信发送器
- android 短信发送器
- Android短信发送器
- android短信发送器
- Android短信发送器
- Android短信发送器
- Android短信发送器
- Android短信发送器
- Android短信发送器
- android 短信发送器
- Apaceh配置httpd-vhosts虚拟主机
- 国产数据库-KingbaseES在linux下的安装
- KingbaseES的standby搭建
- 51nod区间的价值
- KingbaseES的DBLink创建
- 黑马Android:短信发送器
- VMware虚拟机出现Reason: Failed to lock the file
- adb tool device offline
- Redhat6.4下配置本地yum
- redhat6.4下安装Oracle11g
- jsp页面“占位隐藏控件”和“不占位隐藏控件”
- Kingbase在初始化时遇到的错误
- android中keyevent对应的值
- iostat中 %util高 应用延迟高