标签:android blog io ar os java for sp div
file:///F:/workspace3/Android_ver2.5/src/cn/szy/com/MainActivity.java
package cn.szy.com; import java.util.ArrayList; import android.app.Activity; import android.os.Bundle; import android.telephony.SmsManager; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends Activity { /** Called when the activity is first created. */ private Button button; private EditText edittext,number; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); button = (Button)this.findViewById(R.id.button); number = (EditText)this.findViewById(R.id.num); edittext = (EditText)this.findViewById(R.id.content); } public void Opentall(View v){ String num = number.getText().toString(); String content = edittext.getText().toString(); SmsManager manager = SmsManager.getDefault(); ArrayList<String> texts = manager.divideMessage(content); for(String text : texts){ manager.sendTextMessage(num, null, text, null, null); } Toast.makeText(MainActivity.this, "发送成功", Toast.LENGTH_LONG).show(); } }
AndroidManifest.xml
<uses-permission android:name="android.permission.SEND_SMS"/>
标签:android blog io ar os java for sp div
原文地址:http://www.cnblogs.com/sunxun/p/4076446.html