Androidnbsp;Intentnbsp;用法全面总结

2024-01-12 03:32

本文主要是介绍Androidnbsp;Intentnbsp;用法全面总结,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

[代码] 调用拨号程序
    // 给移动客服10086拨打电话
      Uri uri = Uri.parse("tel:10086");
      Intent intent = new Intent(Intent.ACTION_DIAL, uri);
      startActivity(intent);
[代码] 发送短信或彩信
      // 给10086发送内容为“Hello”的短信
      Uri uri = Uri.parse("smsto:10086");
      Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
      intent.putExtra("sms_body", "Hello");
      startActivity(intent);
      // 发送彩信(相当于发送带附件的短信)
      Intent intent = new Intent(Intent.ACTION_SEND);
      intent.putExtra("sms_body", "Hello");
      Uri uri = Uri.parse("content://media/external/images/media/23");
    intent.putExtra(Intent.EXTRA_STREAM, uri);
      intent.setType("image/png");
      startActivity(intent);
[代码] 通过浏览器打开网页
      // 打开Google主页
      Uri uri = Uri.parse("http://www.google.com");
      Intent intent  = new Intent(Intent.ACTION_VIEW, uri);
      startActivity(intent);
[代码] 发送电子邮件
      // 给someone@domain.com发邮件
      Uri uri = Uri.parse("mailto:someone@domain.com");
      Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
      startActivity(intent);
      // 给someone@domain.com发邮件发送内容为“Hello”的邮件
      Intent intent = new Intent(Intent.ACTION_SEND);
      intent.putExtra(Intent.EXTRA_EMAIL, "someone@domain.com");
      intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
      intent.putExtra(Intent.EXTRA_TEXT, "Hello");
      intent.setType("text/plain");
      startActivity(intent);
      // 给多人发邮件
      Intent intent=new Intent(Intent.ACTION_SEND);
    String[] tos = {"1@abc.com", "2@abc.com"}; // 收件人
      String[] ccs = {"3@abc.com", "4@abc.com"}; // 抄送
      String[] bccs = {"5@abc.com", "6@abc.com"}; // 密送
      intent.putExtra(Intent.EXTRA_EMAIL, tos);
      intent.putExtra(Intent.EXTRA_CC, ccs);
      intent.putExtra(Intent.EXTRA_BCC, bccs);
      intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
    intent.putExtra(Intent.EXTRA_TEXT, "Hello");
      intent.setType("message/rfc822");
    startActivity(intent);
[代码] 显示地图与路径规划
    // 打开Google地图中国北京位置(北纬39.9,东经116.3)
      Uri uri = Uri.parse("geo:39.9,116.3");
      Intent intent = new Intent(Intent.ACTION_VIEW, uri);
      startActivity(intent);
      // 路径规划:从北京某地(北纬39.9,东经116.3)到上海某地(北纬31.2,东经121.4)
      Uri uri = Uri.parse("http://maps.google.com/maps?f=d&saddr=39.9 116.3&daddr=31.2 121.4");
      Intent intent = new Intent(Intent.ACTION_VIEW, uri);
      startActivity(intent);
[代码] 播放多媒体
      Intent intent = new Intent(Intent.ACTION_VIEW);
    Uri uri = Uri.parse("file:///sdcard/foo.mp3");
      intent.setDataAndType(uri, "audio/mp3");
      startActivity(intent);
   
      Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");
      Intent intent = new Intent(Intent.ACTION_VIEW, uri);
      startActivity(intent);
[代码] 拍照
      // 打开拍照程序
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
      startActivityForResult(intent, 0);
      // 取出照片数据
      Bundle extras = intent.getExtras();
    Bitmap bitmap = (Bitmap) extras.get("data");
[代码] 获取并剪切图片
    // 获取并剪切图片
      Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
      intent.setType("image/*");
      intent.putExtra("crop", "true"); // 开启剪切
    intent.putExtra("aspectX", 1); // 剪切的宽高比为1:2
      intent.putExtra("aspectY", 2);
      intent.putExtra("outputX", 20); // 保存图片的宽和高
      intent.putExtra("outputY", 40);
    intent.putExtra("output", Uri.fromFile(new File("/mnt/sdcard/temp"))); // 保存路径
      intent.putExtra("outputFormat", "JPEG");// 返回格式
      startActivityForResult(intent, 0);
      // 剪切特定图片
      Intent intent = new Intent("com.android.camera.action.CROP");
      intent.setClassName("com.android.camera", "com.android.camera.CropImage");
      intent.setData(Uri.fromFile(new File("/mnt/sdcard/temp")));
      intent.putExtra("outputX", 1); // 剪切的宽高比为1:2
    intent.putExtra("outputY", 2);
      intent.putExtra("aspectX", 20); // 保存图片的宽和高
  intent.putExtra("aspectY", 40);
      intent.putExtra("scale", true);
      intent.putExtra("noFaceDetection", true);
    intent.putExtra("output", Uri.parse("file:///mnt/sdcard/temp"));
      startActivityForResult(intent, 0);
[代码] 打开Google Market
      // 打开Google Market直接进入该程序的详细页面
      Uri uri = Uri.parse("market://details?id=" + "com.demo.app");
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
      startActivity(intent);
[代码] 安装和卸载程序
      Uri uri = Uri.fromParts("package", "com.demo.app", null);
      Intent intent = new Intent(Intent.ACTION_DELETE, uri);
      startActivity(intent);
[代码] 进入设置界面

    // 进入无线网络设置界面(其它可以举一反三)
  Intent intent = new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS);
    startActivityForResult(intent, 0);

这篇关于Androidnbsp;Intentnbsp;用法全面总结的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/596672

相关文章

HarmonyOS学习(七)——UI(五)常用布局总结

自适应布局 1.1、线性布局(LinearLayout) 通过线性容器Row和Column实现线性布局。Column容器内的子组件按照垂直方向排列,Row组件中的子组件按照水平方向排列。 属性说明space通过space参数设置主轴上子组件的间距,达到各子组件在排列上的等间距效果alignItems设置子组件在交叉轴上的对齐方式,且在各类尺寸屏幕上表现一致,其中交叉轴为垂直时,取值为Vert

学习hash总结

2014/1/29/   最近刚开始学hash,名字很陌生,但是hash的思想却很熟悉,以前早就做过此类的题,但是不知道这就是hash思想而已,说白了hash就是一个映射,往往灵活利用数组的下标来实现算法,hash的作用:1、判重;2、统计次数;

git使用的说明总结

Git使用说明 下载安装(下载地址) macOS: Git - Downloading macOS Windows: Git - Downloading Windows Linux/Unix: Git (git-scm.com) 创建新仓库 本地创建新仓库:创建新文件夹,进入文件夹目录,执行指令 git init ,用以创建新的git 克隆仓库 执行指令用以创建一个本地仓库的

二分最大匹配总结

HDU 2444  黑白染色 ,二分图判定 const int maxn = 208 ;vector<int> g[maxn] ;int n ;bool vis[maxn] ;int match[maxn] ;;int color[maxn] ;int setcolor(int u , int c){color[u] = c ;for(vector<int>::iter

整数Hash散列总结

方法:    step1  :线性探测  step2 散列   当 h(k)位置已经存储有元素的时候,依次探查(h(k)+i) mod S, i=1,2,3…,直到找到空的存储单元为止。其中,S为 数组长度。 HDU 1496   a*x1^2+b*x2^2+c*x3^2+d*x4^2=0 。 x在 [-100,100] 解的个数  const int MaxN = 3000

状态dp总结

zoj 3631  N 个数中选若干数和(只能选一次)<=M 的最大值 const int Max_N = 38 ;int a[1<<16] , b[1<<16] , x[Max_N] , e[Max_N] ;void GetNum(int g[] , int n , int s[] , int &m){ int i , j , t ;m = 0 ;for(i = 0 ;

bytes.split的用法和注意事项

当然,我很乐意详细介绍 bytes.Split 的用法和注意事项。这个函数是 Go 标准库中 bytes 包的一个重要组成部分,用于分割字节切片。 基本用法 bytes.Split 的函数签名如下: func Split(s, sep []byte) [][]byte s 是要分割的字节切片sep 是用作分隔符的字节切片返回值是一个二维字节切片,包含分割后的结果 基本使用示例: pa

从状态管理到性能优化:全面解析 Android Compose

文章目录 引言一、Android Compose基本概念1.1 什么是Android Compose?1.2 Compose的优势1.3 如何在项目中使用Compose 二、Compose中的状态管理2.1 状态管理的重要性2.2 Compose中的状态和数据流2.3 使用State和MutableState处理状态2.4 通过ViewModel进行状态管理 三、Compose中的列表和滚动

go基础知识归纳总结

无缓冲的 channel 和有缓冲的 channel 的区别? 在 Go 语言中,channel 是用来在 goroutines 之间传递数据的主要机制。它们有两种类型:无缓冲的 channel 和有缓冲的 channel。 无缓冲的 channel 行为:无缓冲的 channel 是一种同步的通信方式,发送和接收必须同时发生。如果一个 goroutine 试图通过无缓冲 channel

9.8javaweb项目总结

1.主界面用户信息显示 登录成功后,将用户信息存储在记录在 localStorage中,然后进入界面之前通过js来渲染主界面 存储用户信息 将用户信息渲染在主界面上,并且头像设置跳转,到个人资料界面 这里数据库中还没有设置相关信息 2.模糊查找 检测输入框是否有变更,有的话调用方法,进行查找 发送检测请求,然后接收的时候设置最多显示四个类似的搜索结果