<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通知
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"/>