Android Intent的几种用法全面总结

startActivity(it);

拨打电话:

调用拨号程序 Uri uri = Uri.parse(“tel:xxxxxx”);

Inte
nt it = new Intent(Intent.ACTION_DIAL, uri);

startActivity(it);

Uri uri = Uri.parse(“tel.xxxxxx”);

Intent it =new Intent(Intent.ACTION_CALL,uri);

要使用这个必须在配置文件中加入

发送SMS/MMS

调用发送短信的程序 Intent it = new Intent(Intent.ACTION_VIEW);

it.putExtra(“sms_body”, “The SMS text”);

it.setType(“vnd.android-dir/mms-sms”);

startActivity(it);

发送短信 Uri uri = Uri.parse(“smsto:0800000123”);

Intent it = new Intent(Intent.ACTION_SENDTO, uri);

it.putExtra(“sms_body”, “The SMS text”);

startActivity(it);

发送彩信 Uri uri = Uri.parse(“content://media/external/images/media/23”);

Intent it = new Intent(Intent.ACTION_SEND);

it.putExtra(“sms_body”, “some text”);

it.putExtra(Intent.EXTRA_STREAM, uri);

it.setType(“image/png”);

startActivity(it);

发送Email

Uri uri = Uri.parse(“mailto:xxx@abc.com”);

Intent it = new Intent(Intent.ACTION_SENDTO, uri);

startActivity(it);

Intent it = new Intent(Intent.ACTION_SEND);

it.putExtra(Intent.EXTRA_EMAIL, “me@abc.com”);

it.putExtra(Intent.EXTRA_TEXT, “The email body text”);

it.setType(“text/plain”);

startActivity(Intent.createChooser(it, “Choose Email Client”));

Intent it=new Intent(Intent.ACTION_SEND);

String[] tos={“me@abc.com”};

String[] ccs={“you@abc.com”};

it.putExtra(Intent.EXTRA_EMAIL, tos);

it.putExtra(Intent.EXTRA_CC, ccs);

it.putExtra(Intent.EXTRA_TEXT, “The email body text”);

it.putExtra(Intent.EXTRA_SUBJECT, “The email subject text”);

it.setType(“message/rfc822”);

startActivity(Intent.createChooser(it, “Choose Email Client”));

添加附件 Intent it = new Intent(Intent.ACTION_SEND);

it.putExtra(Intent.EXTRA_SUBJECT, “The email subject text”);

it.putExtra(Intent.EXTRA_STREAM, “file:///sdcard/mysong.mp3”);

sendIntent.setType(“audio/mp3”);

startActivity(Intent.createChooser(it, “Choose Email Client”));

播放多媒体

Intent it = new Intent(Intent.ACTION_VIEW);

Uri uri = Uri.parse(“file:///sdcard/song.mp3”);
it.setDataAndType(uri, “audio/mp3”);

相关推荐

  1. Android Intent用法全面总结

    2024-06-18 11:16:06       34 阅读
  2. Rabbitmq模式总结

    2024-06-18 11:16:06       52 阅读
  3. MySQL5.7安装方式总结

    2024-06-18 11:16:06       56 阅读
  4. 复习-详解查看Oracle用户权限方法

    2024-06-18 11:16:06       67 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-06-18 11:16:06       91 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-06-18 11:16:06       97 阅读
  3. 在Django里面运行非项目文件

    2024-06-18 11:16:06       78 阅读
  4. Python语言-面向对象

    2024-06-18 11:16:06       88 阅读

热门阅读

  1. css3多列布局

    2024-06-18 11:16:06       47 阅读
  2. 在 Python 3 中删除字符串文字前面的“b“字符

    2024-06-18 11:16:06       33 阅读
  3. 在无线网中 2.4G、5G、WiFi6、WiFi7 都是什么意思?

    2024-06-18 11:16:06       33 阅读
  4. Oracle中常用特殊字符chr值

    2024-06-18 11:16:06       31 阅读
  5. 这些常用 MySQL 用法,99% 的人都不知道!

    2024-06-18 11:16:06       33 阅读
  6. 数据仓库之主题域

    2024-06-18 11:16:06       30 阅读
  7. python,ipython 和 jupyter notebook 之间的关系

    2024-06-18 11:16:06       32 阅读
  8. LeetCode //MySQL - 178. Rank Scores

    2024-06-18 11:16:06       37 阅读