点击Android中的网址即可打开我的应用

时间:2013-11-18 23:44:05

标签: 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>

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

我做错了什么? 的问候,

3 个答案:

答案 0 :(得分:3)

在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);

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

答案 1 :(得分:1)

试试这个

<data
            android:host="imintheapp.com"
            android:path="/events/get/"
            android:scheme="http" />

答案 2 :(得分:1)

我认为您应该查看Mainfest文件的intent-filter元素。具体来说,请查看data子元素的文档。

再次阅读这些文档。

我还建议你阅读this Que.

的第二个问题