android 发送短信
所需权限<uses-permission android:name="android.permission.SEND_SMS" />
public class MessageActivity extends Activity { private EditText number; private EditText content; private Button button; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); number = (EditText) this.findViewById(R.id.number); content = (EditText) this.findViewById(R.id.content); button = (Button) this.findViewById(R.id.button); button.setOnClickListener(ButtonOnClickListener); } private OnClickListener ButtonOnClickListener = new OnClickListener(){ @Override public void onClick(View v) { String numberText = number.getText().toString(); String contentText = content.getText().toString(); SmsManager sms = SmsManager.getDefault(); ArrayList<String> texts = sms.divideMessage(contentText); for(String t : texts){ sms.sendTextMessage(numberText, null, t, null, null); } Toast.makeText(getApplicationContext(), R.string.success, Toast.LENGTH_LONG); } }; }