首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

Intent 跟 Intent Filter 官方文档读后总结

2012-06-27 
Intent 和 Intent Filter 官方文档读后总结?语法:data android:hoststringandroid:mimeTypestringa

Intent 和 Intent Filter 官方文档读后总结

?


语法:

<data android:host="string"

android:mimeType="string"

android:path="string"

android:pathPattern="string"

android:pathPrefix="string"

android:port="string"

android:scheme="string" />

可以分开写,如:

<data android:scheme="something" android:host="project.example.com" android:port="80"/>

等同于这样写:

<data android:scheme="something"/>

<data android:host="project.example.com"/>

<data android:port="80"/>


在java代码里,Uri的格式:scheme://host:port/path or pathPrefix or pathPattern

注意:不可以同时出现第4点的标签对,即上面那条。

6.在<intent-filter></intent-filter>里可以有多个<action android:name="xxxx"> ,只需匹配其中一个即可。

7.当匹配不上任何Activity的话,会发生异常,跳出对话框:很抱歉...某某应用程序意外停止,请重试。

8.上面所说的全部适用于Service和BroadcastReceiver,只需把<activity ...></activity>换成<service ...></service>或<receiver ...></receiver>即可。

9.刚参考了一下packages\apps\HTMLViewer\AndroidManifest.xml,第4和第5条应该是不冲突才对,但是实际测试中却是冲突,暂时未到找原因。匹配方式请看:用于打开HTML文件的intent


在被启动的Activity(本例为MyActivityTwo)里接收数据:

Intent intent = getIntent();

String intentCategories = intent.getCategories()

String intentType = intent.getType();

Uri uri = intent.getData();

String uriScheme = uri.getScheme();

String uriPath = uri.getPath();

String uriHost = uri.getHost();

String uriEncodedPath = uri.getEncodedPath();

?

?

?

原文http://www.eoeandroid.com/thread-94077-1-1.html

说明http://www.cnblogs.com/Android_2011/archive/2011/06/12/2078643.html

?

?

?

?

?

?

热点排行