intent的常用方法

intent的常用方法

ID:47041425

大小:52.00 KB

页数:5页

时间:2019-07-06

intent的常用方法_第1页
intent的常用方法_第2页
intent的常用方法_第3页
intent的常用方法_第4页
intent的常用方法_第5页
资源描述:

《intent的常用方法》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、Intent在Android中的几种用法如果是从BroadcastReceiver启动一个新的Activity, 不要忘记i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); publicclassMyReceiverextendsBroadcastReceiver{publicstaticfinalStringaction="acc"; publicvoidonReceive(Contextcontext,Intentintent){  Intenti=newIntent(context,Receiver

2、ed.class);  i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);  context.startActivity(i); }}1.指定action和type//SIMimport       IntentimportIntent=newIntent(Intent.ACTION_VIEW);       importIntent.setType("vnd.android.cursor.item/sim-contact");       importIntent.setClassName("com.a

3、ndroid.phone","com.android.phone.SimContacts");       menu.add(0,0,0,R.string.importFromSim)               .setIcon(R.drawable.ic_menu_import_contact)               .setIntent(importIntent);               2.指定action,data和type(1)隐式查找type示例代码:uri:content://simcontacts/simPe

4、ople/(id)intent=newIntent("android.intent.action.SIMEDIT",uri);           startActivity(intent);程序会很据data中的uri去查找匹配的type(必须的)           provider中的getType()           caseSIM_PEOPLE_ID:          return"vnd.android.cursor.item/sim-contact"; 配置文件中的filter设定         AndroidMan

5、ifest.xml                                                           也可

6、以自己设定type,但只能使用setDataAndType()       3.其他设定intent的属性方式  IntentsetComponent(ComponentNamecomponent)  IntentsetClassName(ContextpackageContext,StringclassName)  IntentsetClassName(StringpackageName,StringclassName)  IntentsetClass(ContextpackageContext,Classcls)   Inten

7、t应该算是Android中特有的东西。你可以在Intent中指定程序要执行的动作(比如:view,edit,dial),以及程序执行到该动作时所需要的资料。都指定好后,只要调用startActivity(),Android系统会自动寻找最符合你指定要求的应用程序,并执行该程序。下面列出几种Intent的用法显示网页:1.Uriuri=Uri.parse("http://www.google.com");2.Intentit  =newIntent(Intent.ACTION_VIEW,uri);3.startActivity(it);显示

8、地图:1.Uriuri=Uri.parse("geo:38.899533,-77.036476");2.Intentit=newIntent(Intent.Action_VIEW,uri);3

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。