在Android的一个URL时,点击我的应用程序被打开 [英] My app is opened when clicking on a URL in Android

查看:102
本文介绍了在Android的一个URL时,点击我的应用程序被打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经为了从某些类型的URL启动我的应用程序定义的意图过滤器。的一点是,它启动对所有类型的链接,并且我仅希望被推出一个具体主机名。这里是我的清单:

I have defined an intent filter in order to launch my app from some kinds of URLs. The point is that it is launched for all the kinds of links, and I only want to be launched for a concrete host name. Here is my manifest:

    <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/获得/ XXXXXXXX 其中xxxxxxxx是字母数字字符串。

I need to open my app ONLY in the following cases: http://imintheapp.com/events/get/xxxxxxxx where xxxxxxxx is an alphanumeric string.

我做错了吗?
问候,

What I am doing wrong? Regards,

推荐答案

添加此code在Menifest.xml

Add this code in 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>

有关测试创建另一个项目,并低于code运行

For test create another project and run below code

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

您也可以在通过参数中的链接
更多信息
http://paragchauhan2010.blogspot.com/2013/03/make-link-in-android-browser-start-up.html

这篇关于在Android的一个URL时,点击我的应用程序被打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆