2019独角兽企业重金招聘Python工程师标准>>>

Intent应该算是Android中特有的东西。你可以在Intent中指定程序要执行的动作(比如:view,edit,dial),以及程序执行到该动作时所需要的资料。都指定好后,只要调用startActivity(),Android系统会自动寻找最符合你指定要求的应用程序,并执行该程序。

下面列出几种Intent的用法
显示网页:

  1. Uri uri = Uri.parse("http://www.google.com");
  2. Intent it  = new Intent(Intent.ACTION_VIEW,uri);
  3. startActivity(it);

复制代码

显示地图:

  1. Uri uri = Uri.parse("geo:38.899533,-77.036476");
  2. Intent it = new Intent(Intent.Action_VIEW,uri);
  3. startActivity(it);

复制代码

路径规划:

  1. Uri uri = Uri.parse("http://maps.google.com/maps?f=d&saddr=startLat%20startLng&daddr=endLat%20endLng&hl=en");
  2. Intent it = new Intent(Intent.ACTION_VIEW,URI);
  3. startActivity(it);

复制代码

拨打电话:
调用拨号程序

  1. Uri uri = Uri.parse("tel:xxxxxx");
  2. Intent it = new Intent(Intent.ACTION_DIAL, uri);
  3. startActivity(it);

复制代码

  1. Uri uri = Uri.parse("tel.xxxxxx");
  2. Intent it =new Intent(Intent.ACTION_CALL,uri);
  3. 要使用这个必须在配置文件中加入<uses-permission id="android.permission.CALL_PHONE" />

复制代码

发送SMS/MMS
调用发送短信的程序

  1. Intent it = new Intent(Intent.ACTION_VIEW);
  2. it.putExtra("sms_body", "The SMS text");
  3. it.setType("vnd.android-dir/mms-sms");
  4. startActivity(it);

复制代码

发送短信

  1. Uri uri = Uri.parse("smsto:0800000123");
  2. Intent it = new Intent(Intent.ACTION_SENDTO, uri);
  3. it.putExtra("sms_body", "The SMS text");
  4. startActivity(it);

复制代码

发送彩信

  1. Uri uri = Uri.parse("content://media/external/images/media/23");
  2. Intent it = new Intent(Intent.ACTION_SEND);
  3. it.putExtra("sms_body", "some text");
  4. it.putExtra(Intent.EXTRA_STREAM, uri);
  5. it.setType("image/png");
  6. startActivity(it);

复制代码

发送Email

  1. Uri uri = Uri.parse("mailto:xxx@abc.com");
  2. Intent it = new Intent(Intent.ACTION_SENDTO, uri);
  3. startActivity(it);

复制代码

  1. Intent it = new Intent(Intent.ACTION_SEND);
  2. it.putExtra(Intent.EXTRA_EMAIL, "me@abc.com");
  3. it.putExtra(Intent.EXTRA_TEXT, "The email body text");
  4. it.setType("text/plain");
  5. startActivity(Intent.createChooser(it, "Choose Email Client"));

复制代码

  1. Intent it=new Intent(Intent.ACTION_SEND);
  2. String[] tos={"me@abc.com"};
  3. String[] ccs={"you@abc.com"};
  4. it.putExtra(Intent.EXTRA_EMAIL, tos);
  5. it.putExtra(Intent.EXTRA_CC, ccs);
  6. it.putExtra(Intent.EXTRA_TEXT, "The email body text");
  7. it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
  8. it.setType("message/rfc822");
  9. startActivity(Intent.createChooser(it, "Choose Email Client"));

复制代码

添加附件

  1. Intent it = new Intent(Intent.ACTION_SEND);
  2. it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
  3. it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/mysong.mp3");
  4. sendIntent.setType("audio/mp3");
  5. startActivity(Intent.createChooser(it, "Choose Email Client"));

复制代码

播放多媒体

  1. Intent it = new Intent(Intent.ACTION_VIEW);
  2. Uri uri = Uri.parse("file:///sdcard/song.mp3");
  3. it.setDataAndType(uri, "audio/mp3");
  4. startActivity(it);

复制代码

  1. Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");
  2. Intent it = new Intent(Intent.ACTION_VIEW, uri);
  3. startActivity(it);

复制代码

Uninstall 程序

  1. Uri uri = Uri.fromParts("package", strPackageName, null);
  2. Intent it = new Intent(Intent.ACTION_DELETE, uri);
  3. startActivity(it);

复制代码

uninstall apk

  1. Uri uninstallUri = Uri.fromParts("package", "xxx", null);
  2. returnIt = new Intent(Intent.ACTION_DELETE, uninstallUri);

复制代码

install apk

  1. Uri installUri = Uri.fromParts("package", "xxx", null);
  2. returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri);

复制代码

play audio

  1. Uri playUri = Uri.parse("file:///sdcard/download/everything.mp3");
  2. returnIt = new Intent(Intent.ACTION_VIEW, playUri);

复制代码

  1. //发送附件
  2. Intent it = new Intent(Intent.ACTION_SEND);
  3. it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
  4. it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/eoe.mp3");
  5. sendIntent.setType("audio/mp3");
  6. startActivity(Intent.createChooser(it, "Choose Email Client"));
  1. //搜索应用
  2. Uri uri = Uri.parse("market://search?q=pname:pkg_name");
  3. Intent it = new Intent(Intent.ACTION_VIEW, uri);
  4. startActivity(it);
  5. //where pkg_name is the full package path for an application
  6. //显示指定应用的详细页面(这个好像不支持了,找不到app_id)
  7. Uri uri = Uri.parse("market://details?id=app_id");
  8. Intent it = new Intent(Intent.ACTION_VIEW, uri);
  9. startActivity(it);
  10. //where app_id is the application ID, find the ID
  11. //by clicking on your application on Market home
  12. //page, and notice the ID from the address bar

玩过Android的都清楚, Camera有俩种模式:照相模式和录像模式。
启动录像模式:
Intent i = new Intent();
i.setAction(“android.media.action.VIDEO_CAMERA“);
startActivity(i);

启用照相模式:
Intent i = new Intent();
i.setAction(“android.media.action.STILL_IMAGE_CAMERA“);
startActivity(i);

转载于:https://my.oschina.net/zhangjie830621/blog/161891

调用android系统自带功能相关推荐

  1. 调用Android系统自带相机拍照,从相册中获取图片

    一,前言: 在日常的手机应用开发过程中,经常会遇到上传图片的需求,像上传头像之类的,这就需要调用系统的相机,相册获取照片.但是在Android 系统7.0之后认为这种操作是不安全的,这篇文章主要就是记 ...

  2. android 调用原生分享功能,调用Android 系统自带分享功能

    1. 设置Intent的action为Intent.ACTION_SEND. 2. 把要分享的数据通过.putExtra()传入intent. 3. 设置类型.setType(). 4.startAc ...

  3. android 调用系统下载apk,如何在自己的App中调用Android系统自带的安装/卸载程序...

    AppUtils里面写了如何安装和卸载apk(这段代码出自这里:点击打开链接~),这里的安装和卸载调用的是Android本身的一个安装卸载,所以可能页面不会太优雅,并不符合商业App的期望,如果要做到 ...

  4. android 调用系统自带文件管理器_编写使用Android 系统自带的文字转语音代码

    调用Android系统语音TextToSpeech实例对象 具体代码写法如下: TextToSpeech mTextToSpeech = new TextToSpeech(this, new Text ...

  5. 为Android系统定制重启功能

    按计划每周更新一篇技术博文,第二篇:<为Android系统定制重启功能> 一.Android系统重启的实现方式 1.广播方式 之前的博文介绍过这种方式<使用广播实现的Android关 ...

  6. miui主题风格_一种android系统换肤功能的设计,董红光:MIUI主题风格.pdf

    MIUI主题风格主题风格主题风格主题风格 一种Android系统换肤功能的设计思路 董红光 2/29/2012 "主题"是什么 ? Symbian的"主题" A ...

  7. android 系统自带主题样式及自定义主题样式

    From: http://blog.csdn.net/dawanganban/article/details/17732701 http://www.cnblogs.com/bluestorm/arc ...

  8. Android系统自带主题样式(android:theme),Android Dialog 系统样式

    部分转载:http://stephen830.iteye.com/blog/1129203 ,  http://blog.sina.com.cn/s/blog_3e333c4a0102vk0f.htm ...

  9. Android系统自带样式(android:theme)(转)

    Android系统自带样式(android:theme)(转) android:theme="@android:style/Theme.Dialog" : Activity显示为对 ...

最新文章

  1. 每日一皮:当产品经理试图让程序员冷静下来的时候...
  2. 《微机原理及接口技术》第05章在线测试
  3. Spring MVC:资源
  4. centos7.3 安装 mysql-5.7.13
  5. 校招生大规模涨薪、再扩招10000人?大厂抢人有多野?
  6. [ACM] hdu 2079 选课时间(普通型母函数)
  7. 信息安全工程师 学习笔记 完结
  8. 2020年副业推荐,介绍网络兼职的文章
  9. 【STC15】通过PWM波实现呼吸灯效果
  10. 2021年社招字节跳动测试开发工程师面试题
  11. 一种简单的DWG在线浏览方法
  12. Wlan学习—无线网络安全
  13. 周末阅读:北漂程序员边城的幸福生活
  14. 截图工具(窗体永远前置)
  15. 为什么网上都说 AirPods 3 音质不如AirPods Pro?
  16. 那些怪异的量化交易策略
  17. IDEA中dbug调试图标解释
  18. Lumia 1020 诞生:诺基亚拍照技术的一次狂欢
  19. 求助:用Python获取百度云服务access_token总是失败
  20. 搭建MPI并行计算环境并计算pi值[windows 和 Ubuntu]

热门文章

  1. 爬取百度百科上中国所有城市的信息
  2. Ubuntu 16.04禁用来宾账号(Guest User)
  3. Quartz.NET在ASP.NET 中使用
  4. linux下的mysql数据库大小写问题
  5. 模板方法模式 Template method 行为型 设计模式(二十六)
  6. (PHP7内核剖析-3) 变量
  7. 使用canvas绘制圆形进度条
  8. 使用EF操作Oracle数据库小计
  9. Python:打印目录下最大的十个文件
  10. VC调试篇:减少运行时错误,中断所有异常