单击 Android 中的 URL 时会打开我的应用程序

Did*_*era 5 android

我定义了一个意图过滤器,以便从某些类型的 URL 启动我的应用程序。重点是它是针对所有类型的链接启动的,而我只想针对具体的主机名启动。这是我的清单:

    <activity
        android:name="com.imin.SplashActivity"
        android:label="@string/app_name"
        android:launchMode="singleTask"
        android:logo="@drawable/img_action_icon"
        android:screenOrientation="portrait"
        android:theme="@style/AppTeme.Fullscreen" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <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="imintheapp.com"
                android:pathPrefix="/events/get/"
                android:scheme="http" />
        </intent-filter>
    </activity>
Run Code Online (Sandbox Code Playgroud)

我仅需要在以下情况下打开我的应用程序:http://imintheapp.com/events/get/xxxxxxxx,其中 xxxxxxxx 是字母数字字符串。

我做错了什么?问候,

Par*_*han 3

在 Menifest.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:host="www.parag-chauhan.com"
                    android:path="/test"
                    android:scheme="http" />
            </intent-filter>
Run Code Online (Sandbox Code Playgroud)

为了测试创建另一个项目并运行下面的代码

Intent i = new Intent(Intent.ACTION_VIEW , Uri.parse("http://www.parag-chauhan.com/test"));
startActivity(i);
Run Code Online (Sandbox Code Playgroud)

您还可以pass parameter在链接中获取更多信息 http://paragchauhan2010.blogspot.com/2013/03/make-link-in-android-browser-start-up.html