android的uri的组成为:
scheme://authority/path/queryParts
其中的authority又分为host:port
android的scheme协议下的uri格式:
scheme://host:port/path/queryParameter=queryString
一.唤起外部应用的activity
1.目标activity必须在其AndroidManifest.xml中配置如下过滤器:
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="artist"
android:host="first"
android:path="/enter"/>
</intent-filter>
2.然后启动方式就为:
Intent intent = new Intent();
intent.setData(Uri.parse("artist://first/enter"));
startActivity(intent);
二.唤起应用内部activity
方式一:唤起外部应用的activity一样的步骤
方式二:
1.目标activity必须在其AndroidManifest.xml中配置如下过滤器:
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="artist"
android:host="first"
android:path="/enter"/>
</intent-filter>
2.然后启动方式为:
WebView.loadUrl("artist://first/enter");
当然< data/>中还可以配置更多的属性:
<data android:scheme="string"
android:host="string"
android:port="string"
android:path="string"
android:pathPattern="string"
android:pathPrefix="string"
android:mimeType="string" />
scheme 路径的规则:
<scheme> :// <host> : <port> [<path>|<pathPrefix>|<pathPattern>]
scheme开头 :// 主机名 : 端口号 / [路径/参数]
类似于做web开发中的 https://loaclhost:8080/index.jsp?PHONE=10086