阅读更多 首先发送短信是需要权限的:
     


程序主入口:

package com.example.message;import android.app.Activity;import android.content.Intent;import android.net.Uri;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.EditText;public class MainActivity extends Activity {private EditText phone ,message;private Button sendbtn;protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);phone = (EditText) findViewById(R.id.phone);message = (EditText) findViewById(R.id.message);sendbtn = (Button) findViewById(R.id.sendbtn);//点击发送短信sendbtn.setOnClickListener(new OnClickListener() {public void onClick(View v) {String p = phone.getText().toString();String m = message.getText().toString();Uri smstoUri = Uri.parse("smsto:"); // 解析地址Intent intent = new Intent(Intent.ACTION_VIEW,smstoUri);intent.putExtra("address",p); // 没有电话号码的话为默认的,即显示的时候是为空的intent.putExtra("sms_body",m); // 设置发送的内容intent.setType("vnd.android-dir/mms-sms");startActivity(intent);}});}}
  • message.rar (1.1 MB)
  • 下载次数: 5

更多相关文章

  1. Android解析包名信息
  2. android HTTP 通信, XML 解析, 通过 Hander 实现异步消息处理
  3. android http请求并解析返回的xml
  4. Android之Spinner解析
  5. Android(安卓)Gson 解析泛型报错
  6. android xml操作
  7. android中APK开机自动运行
  8. Android中使用SAX解析XML
  9. android 关于联系人列表的一个类

随机推荐

  1. 答复: Android中使用硬盘模拟SD卡
  2. Android三种定时器的简单使用
  3. 【Android】数据存储之Sharepreference
  4. 浅析Android加载字体包及封装的方法
  5. 【Android】listView动态处理item
  6. Android(安卓)自定义Dialog的实现
  7. How to store an image file to SQliteDB
  8. Android(安卓)6.0蓝牙读写和扫描权限问题
  9. android 使用Http的Get方式读取网络数据
  10. Android(安卓)逆向实战