已阅读5页,还剩1页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Android Intent的幾種用法全面總結Intent, 用法Intent应该算是Android中特有的东西。你可以在Intent中指定程序要执行的动作(比如:view,edit,dial),以及程序执行到该动作时所需要的资料。都指定好后,只要调用startActivity(),Android系统会自动寻找最符合你指定要求的应用程序,并执行该程序。下面列出几种Intent的用法显示网页: 1. Uri uri = Uri.parse();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(/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. 要使用这个必须在配置文件中加入 复制代码发送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.2. Uri uri = Uri.parse(mailto:);3. Intent it = new Intent(Intent.ACTION_SENDTO, uri);4. startActivity(it); 复制代码1. Intent it = new Intent(Intent.ACTION_SEND); 2. it.putExtra(Intent.EXTRA_EMAIL, ); 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=; 3. String ccs=; 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. 2. Intent it = new Intent(Intent.ACTION_VIEW);3. Uri uri = Uri.parse(file:/sdcard/song.mp3);4. it.setDataAndType(uri, audio/mp3);5. 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 apk1. Uri uninstallUri = Uri.fromParts(package, xxx, null);2.3. returnIt = new Intent(Intent.ACTION_DELETE, uninstallUri); 复制代码install apk1. Uri installUri = Uri.fromParts(package, xxx, null);2.3. returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri); 复制代码play audio1. Uri playUri = Uri.parse(file:/sdcard/download/everything.mp3);2.3. 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 application6.7. /显示指定应用的详细页面(这个好像不支持了,找不到app_id)8. Uri uri = Uri.parse(market:/details?id=app_id);9. Intent it = new Intent(Intent.ACTION_VIEW, uri);10. startActivity(it);11. /where app_id is the application ID, find the ID12. /by clicking on your application on Market home13. /page, and notice the ID from the address bar /*/*获得包安装Intent*paramtempFile*return*/publicstaticIntentgetPackageInstallIntent(FiletempFile)UrimPackageURI=Uri.fromFile(tempFile);Intentin=newIntent();in.setAction(Intent.ACTION_VIEW);in.addCategory(Intent.CATEGORY_DEFAULT);in.setCom
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年护理三基知识考试必考练习试题附答案
- 2025年《外贸汇率风险》知识考试题库及答案解析
- 2025年《企业环境、社会和治理报告评价指南》知识考试题库及答案解析
- 2025年《财会实操》知识考试题库及答案解析
- 2025年《保密协议管理制度》知识考试题库及答案解析
- 2025年《国有资产法》知识考试题库及答案解析
- 2025年《财务知识更新机制》知识考试题库及答案解析
- 2025年《安全生产标识》知识考试题库及答案解析
- 2025年《教育法律法规解读》知识考试题库及答案解析
- 2025年《物权法司法解释案例分析集》知识考试题库及答案解析
- 2024年设计服务协议标准文本版
- 01685《动漫艺术概论》历年考试真题试题库(含答案)
- 2024年全国“红旗杯”班组长大赛(复赛)备考试题库(简答、案例分析题)
- 土建劳务扩大分包招标文件模板
- 初中语文2024届中考成语专项练习(共20道选择题附参考答案)
- 中国音乐史智慧树知到期末考试答案章节答案2024年聊城大学
- 单位涉密人员保密审查表
- 中外儿童文学经典阅读与写作智慧树知到期末考试答案2024年
- 出血中风病护理查房
- 《钢筋桁架楼承板应用技术规程》
- 汽车租赁服务投标书
评论
0/150
提交评论