【Android】Android中Intent的用法总结
Intent只在Android中特有,我把它比作一种运载工具,就像飞机一样,会把一些人带到某个地方,而且如果需要的话,还可以找到机上有哪些人员(数据),这就需要另外一些设备来支持(如:Bundle),最后通过引擎(Context的 Activity)来启动。 以下是从网上摘来的:前人已有整理,就方便了我们这些后辈了。 1.显示网页: 2.显示地图: 3.从google搜索内容 4.路径规划 5.拨打电话 6.调用发短信的程序 7.发送短信 8.发送彩信 9.发送Email 10.播放多媒体 11.install apk 12.uninstall apk 13.发送附件
发布日期:2021-06-29 20:54:51
浏览次数:2
分类:技术文章
本文共 3514 字,大约阅读时间需要 11 分钟。
来源:http://blog.sina.com.cn/s/blog_5f1fe33f0100n5e1.html
Java代码
- Uri
uri "http://www.google.com");= Uri.parse( - Intent
it new= Intent(Intent.ACTION_VIEW,uri); - startActivity(it);
Java代码
- Uri
uri "geo:38.899533,-77.036476");= Uri.parse( - Intent
it new= Intent(Intent.Action_VIEW,uri); - startActivity(it);
Java代码
- Intent
intent new= Intent(); - intent.setAction(Intent.ACTION_WEB_SEARCH);
- intent.putExtra(SearchManager.QUERY,"searchString")
- startActivity(intent);
Java代码
- Uri
uri "http://maps.google.com/maps?f=dsaddr=startLat startLng&daddr=endLat endLng&hl=en");= Uri.parse( - Intent
it new= Intent(Intent.ACTION_VIEW,URI); - startActivity(it);
Java代码
- Uri
uri "tel:xxxxxx");= Uri.parse( - Intent
it new= Intent(Intent.ACTION_DIAL, uri); - startActivity(it);
- [color=blue]//要使用这个必须在配置文件
中加入<uses-permission id="android .permission.CALL_PHONE" />[/color]
Java代码
- Intent
it new= Intent(Intent.ACTION_VIEW); - it.putExtra("sms_body",
"The SMS );text" - it.setType("vnd.android-dir/mms-sms");
- startActivity(it);
Java代码
- Uri
uri "smsto:0800000123");= Uri.parse( - Intent
it new= Intent(Intent.ACTION_SENDTO, uri); - it.putExtra("sms_body",
"The SMS );text" - startActivity(it);
Java代码
- Uri
uri "content://media/external/images/media/23");= Uri.parse( - 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);
Java代码
- Uri
uri "mailto:xxx@abc.com");= Uri.parse( - 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= newIntent(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"
Java代码
- Intent
it new= Intent(Intent.ACTION_VIEW); - Uri
uri "file:///sdcard/song.mp3");= Uri.parse( - it.setDataAndType(uri,
"audio/mp3"); - startActivity(it);
-
- Uri
uri "1");= Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, - Intent
it new= Intent(Intent.ACTION_VIEW, uri); - startActivity(it);
Java代码
- Uri
installUri "package",= Uri.fromParts( "xxx", null); - returnIt
= newIntent(Intent.ACTION_PACKAGE_ADDED, installUri);
Java代码
- Uri
uri "package",= Uri.fromParts( strPackageName, null); - Intent
it new= Intent(Intent.ACTION_DELETE, uri); - startActivity(it);
Java代码
- Intent
it new= Intent(Intent.ACTION_SEND); - it.putExtra(Intent.EXTRA_SUBJECT,
"The email );subject text" - it.putExtra(Intent.EXTRA_STREAM,
"file:///sdcard/eoe.mp3"); - sendIntent.setType("audio/mp3");
- startActivity(Intent.createChooser(it,
"Choose Email ));Client"
转载地址:https://dengjin.blog.csdn.net/article/details/41677821 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
不错!
[***.144.177.141]2024年04月20日 15时48分56秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
常见兼容性问题
2019-04-30
promise 浅析
2019-04-30
jQuery源码值得借鉴的地方
2019-04-30
vue、react、angular小小比较
2019-04-30
Node的应用场景
2019-04-30
js数据类型
2019-04-30
js有哪些内置对象
2019-04-30
eval是做什么的
2019-04-30
null,undefined 的区别
2019-04-30
javascript 代码中的“use strict“
2019-04-30
JSON 的了解
2019-04-30
defer和async
2019-04-30
严格模式的限制
2019-04-30
attribute和property的区别是什么
2019-04-30
面向对象编程思想
2019-04-30
reactNative 打包报错 mergeReleaseResources
2019-04-30
对web标准、可用性、可访问性的理解
2019-04-30
JS判断 array 类型
2019-04-30
map与forEach的区别
2019-04-30
箭头函数与普通函数的区别
2019-04-30