从网络 link 启动 android 应用程序 activity 以特定方式开始和结束

Launch android app activity from web link that both starts and ends in a specific way

有没有一种方法可以使用应用程序 activity 启动网络 link,其中网络 link 以特定方式开始和结束?

我想在用户点击网络 link 到特定网站时启动 activity,例如,已在 facebook 上或通过电子邮件共享,并且以该网站开头地址,但前提是它以 "story.html" 结尾。因此,例如 http://www.storyofmathematics.com/ 不会打开应用程序,但 http://www.storyofmathematics.com/story.html

这可以通过将 activity 添加到具有适当意图过滤器的清单中来实现

    <activity
        android:name=".WebActivity"
        android:label="@string/app_name" >
        <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:host="www.storyofmathematics.com"
                android:scheme="http" />
            <data
                android:host="storyofmathematics.com"
                android:scheme="http" />
        </intent-filter>
    </activity>

然后通过 运行 来自 activity

的正则表达式
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class WebActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Intent intent = getIntent();

        if (intent.getDataString().matches(
                "http:\/\/((www.)?)storyofmathematics.com\/.*story.html")) {
            // is match - do stuff
        } else {
            // is not match - do other stuff
        }
    }
}