标签:android
我们来看一个配置间的配置内容,AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.intent"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".BMainActivity"
android:exported="false"
android:label="@string/title_activity_bmain" >
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="com.example.intent.BMainActivity" />
</intent-filter>
</activity>
<activity
android:name=".BMainActivity1"
android:label="@string/title_activity_bmain_activity1" >
<intent-filter >
<category android:name="android.intent.category.DEFAULT"/>
<action android:name="com.example.intent.BMainActivity" />
</intent-filter>
</activity>
</application>
</manifest>
看过上一篇博客后http://blog.csdn.net/gaopeng0071/article/details/45077203,你会发现这里的隐式Intent是不是配置的有问题啊,你看41行与32行的android:name配置相同唉~~,是的是相同,那么我们就来看看,同一android:name跳转不同的activity时,会是什么样子的呢,我们运行下程序,如图。
看到了图片中,Android平台为我们弹窗了2个activity,让我们去选择跳转哪一个。嘿嘿,这么用没错~~~
那如果我们想在后台指定一个怎么做呢,在不修改android:name的前提下,这里就引入了data,进行匹配(类似正则表达式的匹配)。
,
这时我们再条点击跳转的时候,会默认跳转到按照规则匹配到的activity。
Data用法
<data android:host="string"
android:mimeType="string"
android:path="string"
android:pathPattern="string"
android:pathPrefix="string"
android:port="string"
android:scheme="string" />
API描述
Adds a data specification to an intent filter. The specification can be just a data type (the mimeType attribute), just a URI, or both a data type and a URI. A URI is specified by separate attributes for each of its parts:
scheme://host:port/path or pathPrefix or pathPattern
These attributes are optional, but also mutually dependent: If a scheme is not specified for the intent filter, all the other URI attributes are ignored. If a host is not specified for the filter, the port attribute and all the path attributes are ignored.
更多内容详见 Android API
标签:android
原文地址:http://blog.csdn.net/gaopeng0071/article/details/45096895