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

我的应用程序在Android中单击URL时打开,android,Android,我定义了一个意图过滤器,以便从某些URL启动我的应用程序。关键是,它是为所有类型的链接启动的,我只想为一个具体的主机名启动。这是我的舱单: <activity android:name="com.imin.SplashActivity" android:label="@string/app_name" android:launchMode="singleTask" android:logo="@drawable/img

我定义了一个意图过滤器,以便从某些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>
其中xxxxxxxx是一个字母数字字符串

我做错了什么? 您好,

试试这个

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

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

再看一遍那些文件


我还建议您阅读

的第二篇ans,并将此代码添加到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>
您还可以
在链接中传递参数
更多信息

看起来不错。你是说从任何应用程序中的任何链接,无论是哪个域,你的应用程序都是打开url的选项?例如,在Chrome中,如果你点击一个指向www.google.com的链接,你的应用程序要么会启动,要么会呈现给用户一个选项?是的!就是这样,任何url都会打开应用程序,例如www.google.com。我刚刚测试了它,它按预期工作,也就是说,只有表单的意向URI才能解析您的活动。你正在使用哪个版本的Android?@DídacPérez它对我来说运行良好。你是否使用Intent检查了呼叫url?不是在我的设备中。如果我选择“不再问”,像www.google.com这样的链接也会启动我的应用程序。。。这毫无意义。嗨,帕拉格。你能看看这个吗。我也试过同样的方法,但在5.1(棒棒糖)上什么也没发生。我想从浏览器中的任何链接共享到我的应用程序中,我想知道那篇文章的标题。gmail。我真的很感谢你的时间和帮助。Thanks@jason你能再解释一下吗?@Parachouhan谢谢你的回答。我已经将上面的链接添加到我的清单中,只有当我点击任何链接时,它才会打开应用程序,但当我尝试在android中共享我的chrome浏览器链接时,它不会打开应用程序。我不知道为什么会这样。我真的很感谢你的帮助。新增Q谢谢。
Intent i = new Intent(Intent.ACTION_VIEW , Uri.parse("http://www.parag-chauhan.com/test"));
startActivity(i);