一、设计界面

1、布局文件

打开res/layout/activity_main.xml文件。

输入以下代码:

xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical" >

android:id="@+id/textView1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentLeft="true"

android:layout_alignParentTop="true"

android:text="手机号码:" />

android:id="@+id/mobile"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:ems="10" >

android:id="@+id/textView2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="短信内容" />

android:id="@+id/content"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:ems="10" />

android:id="@+id/send"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="发送彩信" />

二、程序文件

打开“src/com.genwoxue.contentprovider_b/MainActivity.java”文件。

然后输入以下代码:

package com.example.intentsmsimage;

import android.net.Uri;

import android.os.Bundle;

import android.app.Activity;

import android.content.Intent;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

import android.widget.TextView;

public class MainActivity extends Activity {

private TextView tvMobile=null;

private TextView tvContent=null;

private Button btnSend=null;

@Override

public void onCreate(Bundle savedInstanceState)

{

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

tvMobile=(TextView)super.findViewById(R.id.mobile);

tvContent=(TextView)super.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("file:///sdcard/girl.jpg");//图片路径

Intent intent=new Intent();

intent.setAction(Intent.ACTION_SEND);

intent.putExtra("address",mobile);//邮件地址

intent.putExtra("sms_body",content);//邮件内容

intent.putExtra(Intent.EXTRA_STREAM,uri);

intent.setType("image/png");//设置类型

MainActivity.this.startActivity(intent);

}

});

}

}

三、配置文件

打开“AndroidManifest.xml”文件。

然后输入以下代码:

package="com.example.intentsmsimage"

android:versionCode="1"

android:versionName="1.0" >

android:minSdkVersion="8"

android:targetSdkVersion="15" />

android:allowBackup="true"

android:icon="@drawable/ic_launcher"

android:label="@string/app_name"

android:theme="@style/AppTheme" >

android:name="com.example.intentsmsimage.MainActivity"

android:label="@string/app_name" >

注意:需要在AndroidManifest.xml文件中添加权限:

四、运行结果

 

android 发送彩信监听,第74章、再识Intent-调用发送彩信程序(从零开始学Android)...相关推荐

  1. Android 截屏监听(截图分享功能实现)

    具体来说就是,检测到了用户在应用内有截图,弹出一个分享界面, 在截图下方添加一个二维码,进行分享. ●●●  前言 Android系统没有直接对截屏事件监听的接口,也没有广播,只能自己动手来丰衣足食, ...

  2. Android 电量变化监听

    Intent.ACTION_BATTERY_CHANGED This is a sticky broadcast containing the charging state, level, and o ...

  3. android 2.1 监听电话状态并自动接听来电

    一.开发环境       Elispse5.5,JDK1.6,Aadroid 2.1 二.开发中使用到的重点技术点:       距离感应(SENSOR_SERVICE ),音讯管理(AUDIO_SE ...

  4. Android的Button监听

    1.android简单按钮监听----单个监听 start = (Button)findViewById(R.id.btnStart); start.setOnClickListener(new On ...

  5. android 软键盘监听、隐藏、显示、点击空白处隐藏和Android KEYCODE 键值大全

    android 软键盘监听.隐藏.显示.点击空白处隐藏. textView.setOnKeyListener(new View.OnKeyListener() {@Overridepublic boo ...

  6. 从零开始学android:Android中的基本控件(上)

    从零开始学android:Android中的基本控件(上) 本章内容较多,下面只贴代码,大家只需要贴到自己eclipse里就知道作用^^! View组件简介 Android中的View组件包含了几乎所 ...

  7. android 发送彩信监听,在Android中发送短信和彩信,监听短信并显示

    发送短信: String body="this is sms demo"; Intent mmsintent = new Intent(Intent.ACTION_SENDTO, ...

  8. android融云监听消息,关于android:融云-IMkit-拦截或监听所有发送消息

    融云 IMkit 拦挡或监听所有发送音讯 最近集成融云 IMkit 的 SDK, 有一个需要是要监听所有收回去的音讯, 依据音讯类型拦挡或者进行批改. 在官网文档上着了一遍, 都没有找到, 偶尔在看 ...

  9. android 7.0 短信监控,Android 7.0 监听网络变化的示例代码

    Android7.0前,Android系统前网络切换时,会发广播,业务只要监听广播即可. public class NetChangeReceiver extends BroadcastReceive ...

最新文章

  1. ​50年来最具影响力的十大编程语言!
  2. (学)DEV在设计界面部分组件显示红叉并报错的问题
  3. 异常“只能在执行Render()的过程中调用RegisterForEventValidation”的解决办法(转)...
  4. 漫谈promise使用场景
  5. keil 查看 stm32 io波形_这样学习STM32单片机,从菜鸟到牛人很简单!
  6. android tabhost 多个activity,Android:TabHost中Activity的生命周期问题
  7. C 和 C++ 文件操作详解
  8. 容器编排技术 -- Kubernetes JSONpath Support
  9. linux不写日志,linux 重要日志
  10. c#自定义类型的转换方式operator,以及implicit(隐式)和explicit (显示)声明的区别...
  11. 《TensorFlow 2.0深度学习算法实战教材》学习笔记(三、TensorFlow 基础)
  12. PCA图像转正C++
  13. 管道爬行机器人内部陀螺仪_管道爬行机器人组成部分
  14. 国家开放大学2021春1315社会调查方法题目
  15. 配置:生产计划参数文件
  16. CAD打断曲线(网页版)
  17. outlook邮箱邮件大小限制_Office Outlook 2010、2013附件大小超过了允许的范围限制三种解决方法图解 – 爱分享...
  18. static修饰的特点
  19. 【零基础-3】PaddlePaddle学习Bert
  20. 【总结】IDS入侵检测系统

热门文章

  1. Ganglia 安装
  2. table colgroup
  3. JZOJ 5947. 【NOIP2018模拟11.02】初音未来(miku)
  4. elementui 隐藏输入框_vue+element-ui实现显示隐藏密码
  5. table表的tr行点击事件,获取对应的table表的第一列的值
  6. (转载)深度剖析 | 可微分学习的自适配归一化 (Switchable Normalization)
  7. scrollTop如何获取
  8. containsKey用法
  9. js时间戳转日期函数
  10. JS逗号运算符的用法详解