Android调用发送短信程序
来源:互联网 发布:淘宝店铺二级域名 编辑:程序博客网 时间:2024/05/12 11:13
代码如下
package com.wenzhi.messagesend;import android.net.Uri;import android.os.Bundle;import android.app.Activity;import android.content.Intent;import android.view.View;import android.widget.Button;import android.widget.TextView;import android.view.View.OnClickListener;/** * 信息发送 * @author xiaowen * @date 2016-1-5 下午6:51:28 * @version 1.0 * @com.wenzhi.messagesend */public class MainActivity extends Activity {private TextView tvMobile; private TextView tvContent; private Button btnSend; @Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);tvMobile=(TextView)findViewById(R.id.mobile); //手机号码 tvContent=(TextView)findViewById(R.id.content); //内容 btnSend=(Button)super.findViewById(R.id.send); btnSend.setOnClickListener(new OnClickListener(){ public void onClick(View v) { //获取手机号码与内容 String mobile=tvMobile.getText().toString(); String content=tvContent.getText().toString(); //发送短信 Uri uri=Uri.parse("smsto:"+mobile); Intent intent=new Intent(); intent.setAction(Intent.ACTION_SENDTO); intent.putExtra("sms_body", content); intent.setType("vnd.android-dir/mms-sms"); intent.setData(uri); MainActivity.this.startActivity(intent); } }); }}
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="手机号码:" /> <EditText android:id="@+id/mobile" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="请输入手机号码" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="短信内容" /> <EditText android:id="@+id/content" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="请输入短信内容" /> <Button android:id="@+id/send" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="发送" /></LinearLayout>
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.wenzhi.messagesend" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" /> <uses-permission android:name="android.permission.SEND_SMS"/><!-- 调用短信 --> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.wenzhi.messagesend.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application></manifest>
效果图
1 0
- Android调用发送短信程序
- Android调用拨号程序,短信发送
- 调用程序发送短信
- android 短信发送程序
- Android短信发送程序
- android调用系统短信发送
- android 调用短信和发送短信
- Android自制发送短信程序
- Android自制发送短信程序
- Android 发送短信小程序
- 调用发送短信程序的Uri
- android调用系统发送短信 和 已发送短信界面
- 调用系统短信程序 Android
- 调用Android系统API发送短信,打电话
- android 中调用接口发送短信
- Android调用系统发送短信界面
- [sms]android 中调用接口发送短信
- Android调用系统发送短信界面
- 如何使用gdb调试段错误
- 绘制模型最小包围盒轮廓
- C程序调用shell脚本共有三种方法
- stm32系统在线调试时程序运行正常输出正常,但是一旦把程序烧写进去则输出不正常
- Async/Await 最佳实践
- Android调用发送短信程序
- Play Framework Ebean 一些数据库查询操作
- CreateProcess()用法
- android 系统相机
- 湖南集训End
- 详解cookie模块
- 修改wamp默认网站根目录
- 机器视觉开源处理库
- android 自定义相机