首页 > 移动平台 > 详细

android第五步短信发送器

时间:2014-03-11 01:30:13      阅读:484      评论:0      收藏:0      [点我收藏+]

<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:orientation="vertical" //别忘了给线性布局富方向
tools:context=".MainActivity" >

 

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minLines ="3" //最少没三行
android:id="@+id/content" />

通知,状态栏通知、对话框通知、TOAST通知

bubuko.com,布布扣

 

private EditText number;
private EditText content;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
number = (EditText)this.findViewById(R.id.number);
content =(EditText)this.findViewById(R.id.content);
Button button = (Button)this.findViewById(R.id.button);
button.setOnClickListener(new ButtonClickLintener());
}
private final class ButtonClickLintener implements View.OnClickListener
{
@Override
public void onClick(View arg0) {
String numbertxt = number.getText().toString();
String contenttxt = content.getText().toString();
SmsManager sms = SmsManager.getDefault(); //短信管理器
ArrayList<String> texts = sms.divideMessage(contenttxt); //拆分短信内容
for(String text : texts){

//1:发送手机号
//2:网络(中国移动,中国联通。。)
//3:内容
//4:短息发送状态
//5:对方接受状态

sms.sendTextMessage(numbertxt, null, text, null, null);
}

//上下文对象,内容,时间长短,最后一定要show()
Toast.makeText(MainActivity.this, R.string.su,Toast.LENGTH_LONG).show();

}

}

所需权限

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

android第五步短信发送器,布布扣,bubuko.com

android第五步短信发送器

原文:http://www.cnblogs.com/zyldream/p/3592195.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!