- 1、本文档共7页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Inten在Android中的几种用法
Intent在Android中的几种用法
分类:?Android2011-11-22 15:17?147人阅读?评论(0)?收藏?举报
转自东方尚智沈大海csdn博客:
如果是从BroadcastReceiver?启动一个新的Activity?,?不要忘记i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);?
[java]?view plaincopy
1. public?class?MyReceiver?extends?BroadcastReceiver{??
2. public?static?final?String?action=acc;??
3. ?public?void?onReceive(Context?context,?Intent?intent)?{??
4. ??Intent?i=new?Intent(context,Receivered.class);??
5. ??i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);??
6. ??context.startActivity(i);??
7. ?}??
1. 指定act?ion 和type?
[java]?view plaincopy
1. Intent?importIntent?=?new?Intent(Intent.ACTION_VIEW);??
2. importIntent.setType(vnd.android.cursor.item/sim-contact);??
3. importIntent.setClassName(com.android.phone,?com.android.phone.SimContacts);??
4. menu.add(0,?0,?0,?R.string.importFromSim).setIcon(R.drawable.ic_menu_import_contact).setIntent(importIntent);??
5. ??????????????????
2. 指定act?ion, da?ta和type?(1)隐式查找type示例代码:
[java]?view plaincopy
1. uri:?content://simcontacts/simPeople/(id)??
2. intent?=?new?Intent(ent.action.SIMEDIT,uri);??
3. ????????????startActivity(intent);??
程序会很据data中的uri去查找匹配的type(必须的) ?
[java]?view plaincopy
1. provider中的getType()??????????????
2. case?SIM_PEOPLE_ID:??
3. ????????????return?vnd.android.cursor.item/sim-contact;????
配置文件中的filter设定 ? ?
[html]?view plaincopy
1. intent-filter??
2. ????????????????action?android:name=ent.action.SIMEDIT?/??
3. ????????????????category?android:name=ent.category.DEFAULT?/????????????
4. ????????????????data?android:mimeType=vnd.android.cursor.item/sim-contact?/??
5. ??????/intent-filter??
也可以自己设定type,但只能使用 setDataAndType() ? ??
3. 其他设定intent的属性方式?
[java]?view plaincopy
1. Intent?setComponent(ComponentName?component)???
2. Intent?setClassName(Context?packageContext,?String?className)??
3. Intent?setClassName(String?packageName,?String?className)??
4. Intent?setClass(Context?packageContext,?Class??cls)??
Intent?应该算是Android中特有的东西。你可以在Intent中指定程序?要执行的动作(比如:view,edit,dial),以及程序执行到该动作时所需要的资料?。都指定好后,只要调用startActivi
您可能关注的文档
- D小居民小有线电视系统设计.doc
- E2-01-01内审检查表-检查内容.doc
- ECO中心CO作业训练教材.doc
- E4阳县黎煤业有限公司投标书-end-8-20.doc
- Egzwe认证知识小常识.doc
- D区冬季施方案.doc
- Edgecm2009R2新增功能简介.doc
- E9A型环树脂的生产工艺及其应用知识.doc
- ERP 专术语(英文缩写).doc
- D工厂蛇形生产线改善.doc
- 2023年度会计硕士每日一练试卷附完整答案详解(各地真题).docx
- 2023年度会计硕士每日一练试卷(真题汇编)附答案详解.docx
- 2023年度会计硕士每日一练试卷(名师推荐)附答案详解.docx
- 2023年度会计硕士每日一练试卷含答案详解【能力提升】.docx
- 2023年度会计硕士每日一练试卷标准卷附答案详解.docx
- 2023年度会计硕士每日一练试卷及答案详解【典优】.docx
- 2023年度会计硕士每日一练试卷含答案详解(精练).docx
- 2023年度会计硕士每日一练试卷及完整答案详解(夺冠).docx
- 2023年度会计硕士每日一练试卷及答案详解【考点梳理】.docx
- 2023年度会计硕士每日一练试卷含答案详解(能力提升).docx
文档评论(0)