失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > android 脚本发短信 Android使用Intent发送短信的实现方法

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

时间:2018-10-14 07:30:55

相关推荐

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

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

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

package com.zhuguangwei;

import android.app.Activity;

import android.content.Intent;

import .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程序设计有所帮助。

如果觉得《android 脚本发短信 Android使用Intent发送短信的实现方法》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。