首页 > 代码库 > Java-Android 之短信发送
Java-Android 之短信发送
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"/>
Java-Android 之短信发送
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。