Android Intent调用大全、系统自带Intent调用大全

Android应用实现安装后自启动 和网上大多数方法一样,使用广播手段: ACTION_PACKAGE_ADDED 一个新应用包已经安装在设备上,数据包括包名(最新安装的包程序不能接收到这个广播) ACTION_PACKAGE_REPLACED 一个新版本的应用安装到设备,替换之前已经存在的版本 ACTION_PACKAGE_CHANGED 一个已存在的应用程序包已经改变,包括包名 ACTION_PACKAGE_REMO 阅读详情

1.从google搜索内容 
Intent intent = new Intent(); 
intent.setAction(Intent.ACTION_WEB_SEARCH); 
intent.putExtra(SearchManager.QUERY,"searchString") 
startActivity(intent); 

2.浏览网页 
Uri uri = Uri.parse("http://www.google.com"); 
Intent it = new Intent(Intent.ACTION_VIEW,uri); 
startActivity(it); 

3.显示地图 
Uri uri = Uri.parse("geo:38.899533,-77.036476"); 
Intent it = new Intent(Intent.Action_VIEW,uri); 
startActivity(it); 

4.路径规划 
Uri uri = Uri.parse("http://maps.google.com/maps?f=dsaddr=startLat%20startLng&daddr=endLat%20endLng&hl=en"); 
Intent it = new Intent(Intent.ACTION_VIEW,URI); 
startActivity(it); 

5.拨打电话 
Uri uri = Uri.parse("tel:xxxxxx"); 
Intent it = new Intent(Intent.ACTION_DIAL, uri); 
startActivity(it); 

6.调用发短信的程序 
Intent it = new Intent(Intent.ACTION_VIEW); 
it.putExtra("sms_body", "The SMS text"); 
it.setType("vnd.Android-dir/mms-sms"); 
startActivity(it); 

7.发送短信 
Uri uri = Uri.parse("smsto:0800000123"); 
Intent it = new Intent(Intent.ACTION_SENDTO, uri); 
it.putExtra("sms_body", "The SMS text"); 
startActivity(it); 
String body="this is sms demo"; 
Intent mmsintent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("smsto", number, null)); 
mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_BODY, body); 
mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_COMPOSE_MODE, true); 
mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_EXIT_ON_SENT, true); 
startActivity(mmsintent); 

8.发送彩信 
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); 
StringBuilder sb = new StringBuilder(); 
sb.append("file://"); 
sb.append(fd.getAbsoluteFile()); 
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mmsto", number, null)); 
// Below extra datas are all optional. 
intent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_SUBJECT, subject); 
intent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_BODY, body); 
intent.putExtra(Messaging.KEY_ACTION_SENDTO_CONTENT_URI, sb.toString()); 
intent.putExtra(Messaging.KEY_ACTION_SENDTO_COMPOSE_MODE, composeMode); 
intent.putExtra(Messaging.KEY_ACTION_SENDTO_EXIT_ON_SENT, exitOnSent); 
startActivity(intent); 

9.发送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")); 

10.播放多媒体 
Intent it = new Intent(Intent.ACTION_VIEW); 
Uri uri = Uri.parse("file:///sdcard/song.mp3"); 
it.setDataAndType(uri, "audio/mp3"); 
startActivity(it); 
Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1"); 
Intent it = new Intent(Intent.ACTION_VIEW, uri); 
startActivity(it); 

11.uninstall apk 
Uri uri = Uri.fromParts("package", strPackageName, null); 
Intent it = new Intent(Intent.ACTION_DELETE, uri); 
startActivity(it); 

12.install apk 
Uri installUri = Uri.fromParts("package", "xxx", null); 
returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri); 

13. 打开照相机 
<1>Intent i = new Intent(Intent.ACTION_CAMERA_BUTTON, null); 
this.sendBroadcast(i); 
<2>long dateTaken = System.currentTimeMillis(); 
String name = createName(dateTaken) + ".jpg"; 
fileName = folder + name; 
ContentValues values = new ContentValues(); 
values.put(Images.Media.TITLE, fileName); 
values.put("_data", fileName); 
values.put(Images.Media.PICASA_ID, fileName); 
values.put(Images.Media.DISPLAY_NAME, fileName); 
values.put(Images.Media.DESCRIPTION, fileName); 
values.put(Images.ImageColumns.BUCKET_DISPLAY_NAME, fileName); 
Uri photoUri = getContentResolver().insert( 
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); 

Intent inttPhoto = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
inttPhoto.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); 
startActivityForResult(inttPhoto, 10); 

14.从gallery选取图片 
Intent i = new Intent(); 
i.setType("image/*"); 
i.setAction(Intent.ACTION_GET_CONTENT); 
startActivityForResult(i, 11); 

15. 打开录音机 
Intent mi = new Intent(Media.RECORD_SOUND_ACTION); 
startActivity(mi); 

16.显示应用详细列表 
Uri uri = Uri.parse("market://details?id=app_id"); 
Intent it = new Intent(Intent.ACTION_VIEW, uri); 
startActivity(it); 
//where app_id is the application ID, find the ID 
//by clicking on your application on Market home 
//page, and notice the ID from the address bar 

刚才找app id未果,结果发现用package name也可以 
Uri uri = Uri.parse("market://details?id=<packagename>"); 
这个简单多了 

17.寻找应用 
Uri uri = Uri.parse("market://search?q=pname:pkg_name"); 
Intent it = new Intent(Intent.ACTION_VIEW, uri); 
startActivity(it); 
//where pkg_name is the full package path for an application 

18.打开联系人列表 
<1> 
Intent i = new Intent(); 
i.setAction(Intent.ACTION_GET_CONTENT); 
i.setType("vnd.android.cursor.item/phone"); 
startActivityForResult(i, REQUEST_TEXT); 

<2> 
Uri uri = Uri.parse("content://contacts/people"); 
Intent it = new Intent(Intent.ACTION_PICK, uri); 
startActivityForResult(it, REQUEST_TEXT); 

19.打开另一程序 
Intent i = new Intent(); 
ComponentName cn = new ComponentName("com.yellowbook.android2", 
"com.yellowbook.android2.AndroidSearch"); 
i.setComponent(cn); 
i.setAction("android.intent.action.MAIN"); 
startActivityForResult(i, RESULT_OK);

 

//调用浏览器

Uri uri = Uri.parse("");
Intent it = new Intent(Intent.ACTION_VIEW,uri);
startActivity(it);
 

//显示某个坐标在地图上

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

//显示路径

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

//拨打电话

Uri uri = Uri.parse("tel:10086");
Intent it = new Intent(Intent.ACTION_DIAL, uri); 
startActivity(it);

Uri uri = Uri.parse("tel.10086");
Intent it =new Intent(Intent.ACTION_CALL,uri);
需要添加 <uses-permission id="android.permission.CALL_PHONE" /> 这个权限到androidmanifest.xml
 

//发送短信或彩信

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:10086"); 
Intent it = new Intent(Intent.ACTION_SENDTO, uri); 
it.putExtra("sms_body", "cwj"); 
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);
 

//发送邮件 
Uri uri = Uri.parse("mailto:android123@163.com");
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
startActivity(it);

Intent it = new Intent(Intent.ACTION_SEND); 
it.putExtra(Intent.EXTRA_EMAIL, android123@163.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_VIEW);
Uri uri = Uri.parse("file:///sdcard/cwj.mp3");
it.setDataAndType(uri, "audio/mp3");
startActivity(it);

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

//卸载APK

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

//卸载apk 2
Uri uninstallUri = Uri.fromParts("package", "xxx", null);
returnIt = new Intent(Intent.ACTION_DELETE, uninstallUri);
 

//安装APK
Uri installUri = Uri.fromParts("package", "xxx", null);
returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri);
 

//播放音乐

Uri playUri = Uri.parse("/sdcard/download/sth.mp3");
returnIt = new Intent(Intent.ACTION_VIEW, playUri);
 

//发送附近

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

//market上某个应用信,pkg_name就是应用的packageName

Uri uri = Uri.parse("market://search?q=pname:pkg_name"); 
Intent it = new Intent(Intent.ACTION_VIEW, uri); 
startActivity(it);


//market上某个应用信息,app_id可以通过www网站看下

Uri uri = Uri.parse("market://details?id=app_id"); 
Intent it = new Intent(Intent.ACTION_VIEW, uri); 
startActivity(it); 
 

//调用搜索

Intent intent = new Intent();
intent.setAction(Intent.ACTION_WEB_SEARCH);
intent.putExtra(SearchManager.QUERY,"android123")
startActivity(intent);
Android Intent调用大全 系统自带Intent调用大全 阅读详情

相关推荐

【计算机视觉】pyrealsense2:Intel RealSense 深度相机的 Python 接口实战指南

pyrealsense2:Intel RealSense 深度相机的 Python 接口实战

weixin_43988131的博客 4350

android.intent.action.PACKAGE_ADDED

String android.content.Intent.ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED" Broadcast Action: A new application package has been installed on the device. The data contains the name o...

yelidemaomao的专栏 5784

BOSS直聘数据采集实战:八爪鱼工具高效爬取职位信息的完整指南

本文提供了一份使用八爪鱼采集器高效爬取BOSS直聘职位信息的完整实战指南。针对非技术用户,详细讲解了从软件安装、网址规律分析到流程配置、数据导出的每一步操作,并分享了提升采集稳定性的高级设置与避坑技巧,帮助用户轻松实现数据采集自动化。

weixin_29061509的博客 1474

android 监听ACTION_PACKAGE_ADDED

我整理的一些关于【Java】的项目学习资料(附讲解~~)和大家一起分享、学习一下:https://d.51cto.com/bLN8S1在Android中监听ACTION_PACKAGE_ADDED的实现 在Android应用中,我们有时需要监听系统的某些事件,特别是与应用程序包相关的事件。本文将详细讲解如何监听ACTIO...

weixin_40318744的博客 989

从零到一:树莓派上的YOLO目标检测实战指南

本文详细介绍了如何在树莓派上部署和优化YOLO目标检测模型,从硬件选型到系统配置,再到模型转换与推理优化。通过对比不同树莓派型号的性能差异,提供实用的配置方案和代码示例,帮助开发者快速实现高效的边缘计算视觉系统。特别推荐使用ONNX格式进行模型转换,以提升在树莓派上的推理效率。

weixin_29046035的博客 1063

Transformers 中的 Softmax 可以并行加速么?

通过融合前两个计算步骤,降低执行Reduce_max和Reduce_sum等操作的通信开销。利用共享内存来存储临时数据,以减少对全局内存的访问成本。

stephen147的博客 1234

Android监听程序的安装和卸载

在android系统中,安装和卸载都会发送广播,当应用安装完成后系统会发android.intent.action.PACKAGE_ADDED广播。可以通过intent.getDataString()获得所安装的包名。当卸载程序时系统发android.intent.action.PACKAGE_REMOVED广播。同样intent.getDataString()获得所卸载的包名。 应用程序无

tianxiangshan的专栏 1万+

Windows环境下Elasticsearch与JDK版本兼容性实战指南

本文详细解析了Windows环境下Elasticsearch与JDK版本的兼容性问题,提供了从版本匹配检查到安装部署的完整实战指南。重点介绍了Elasticsearch 8.x需JDK 17+等关键版本对应关系,并分享多版本JDK共存方案及性能优化技巧,帮助开发者高效避坑。

weixin_29250403的博客 421

Android:收不到应用卸载、替换、安装等广播

最近做项目时需要监听应用的卸载、安装等广播,但一开始使用动态监听方式不能收到广播通知。最后查询相关资料发现,在监听此类动作前需要添加"package"对Intent数据方案进行匹配。 使用方法如下: IntentFilter filter_app = new IntentFilter(); filter_app.addDataScheme("package"); filter...

Arise_Yang的博客 4347

CarSim仿真高级进阶---VS 命令行

仿真软件作为一种强大的工具,被广泛应用于汽车工程领域,本文将介绍如何使用VS命令行进行CarSim仿真的高级进阶操作,我们将结合相关的源代码和描述,帮助读者更好地理解和应用这一功能。打开Visual Studio,在“文件”菜单下选择“新建”->“项目”,然后选择“控制台应用程序”模板,填写项目名称和位置,点击“确定”按钮创建项目。保存源代码后,点击菜单中的“生成”->“生成解决方案”来构建项目,确保构建成功,没有任何错误。点击“编辑”按钮,在弹出的窗口中点击“新建”按钮。,并拥有有效的许可证。

weixin_50547796的博客 308

图像紫边消除(depurple)

对图像紫边形成原因、消除方法进行了介绍。

沧海一升的博客 7565
上一篇: Activity的调用栈分析
下一篇: 在 Android Studio 2.2 中愉快地使用 C/C++
Clarence_zsp
博客等级 码龄11年 12粉丝 19原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值