首页 > 系统 > Android > 正文

Android使用Intent发送短信的实现方法

2019-10-23 20:34:24
字体:
来源:转载
供稿:网友

本文实例讲述了Android使用Intent发送短信的实现方法。分享给大家供大家参考,具体如下:

在一个Activity中使用Intent发送短信

package com.zhuguangwei;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;public class IntentActivity extends Activity {  private Button myButton;  /** Called when the activity is first created. */  @Override  public void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.main);    myButton = (Button) findViewById(R.id.myButton);    myButton.setOnClickListener(new OnClickListener() {      @Override      public void onClick(View v) {        // TODO Auto-generated method stub        // 使用Intent发短信        Uri uri = Uri.parse("smsto:13800000000");        Intent intent = new Intent(Intent.ACTION_SENDTO,uri);        intent.putExtra("sms_body", "The SMS text");        startActivity(intent);      }    });  }}
 


注:相关教程知识阅读请移步到Android开发频道。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表