<span style="font-size:18px;">package com.melody.sendmsg;
import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
public class MainActivity extends Activity {
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.editText1);
EditText et_content = (EditText) findViewById(R.id.editText1);
//获取输入内容和码号
String phone = et_phone.getText().toString();
String content = et_content.getText().toString();
//发短信,直接使用发送短信的API无需启动系统短信应用
SmsManager sm = SmsManager.getDefault();
//把长短信截成若干条短信
ArrayList<String> sms = sm.divideMessage(content);
发短信案例
最新推荐文章于 2021-01-25 17:24:51 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)