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

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

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

无忧一生   2021-03-22 我要评论
想了解Android使用Intent发送短信的实现方法的相关内容吗,无忧一生在本文为您仔细讲解Android Intent发送短信的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:Android,Intent,发送短信,下面大家一起来学习吧。

本文实例讲述了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程序设计有所帮助。

猜您喜欢

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们