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

2024-01-09

我定义了一个意图过滤器,以便从某些类型的 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>

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

我做错了什么? 问候,


在Manifest.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>

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

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

你也可以pass parameter在链接中 欲了解更多信息http://paragchauhan2010.blogspot.com/2013/03/make-link-in-android-browser-start-up.html http://paragchauhan2010.blogspot.com/2013/03/make-link-in-android-browser-start-up.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

单击 Android 中的 URL 时会打开我的应用程序 的相关文章

随机推荐