来自http URL Schema的Android Launch应用程序不起作用

时间:2014-05-27 15:06:17

标签: javascript android android-intent

您好我有点绝望,因为我无法使http架构工作,以便从浏览器/外部链接调用应用程序。

我想从外部链接启动我的应用。在我的应用程序中,我宣布了两个不同的活动来测试。一个人附加了一个http方案,另一个人有一个自定义方案。

活性1:

   <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.myapp.example.com"
                    android:scheme="http" />

            </intent-filter>

活动2:

 <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="myapp.example.com"
                    android:scheme="custom" />
            </intent-filter>

在静态网站上,我创建了以下js代码:

按钮1 - &gt; window.location.replace(&#34;自定义://myapp.example.com");

BUTTON 2 - &gt; window.location.replace(&#34; http://myapp.example.com&#34);

结果如下。从Firefox,通过访问网站,我可以从自定义shema(BUTTON1)调用应用程序,但从http一个,它会导致无效的网站。

我想使http sheme工作,因为我需要从应用程序内的webview调用网站,然后返回到同一个应用程序,但自定义方案不起作用。

有什么想法吗?

任何帮助都将受到赞赏,因为我尝试了很多解决方案,但没有一个能够正常工作谢谢!

1 个答案:

答案 0 :(得分:0)

我认为你在活动1中犯了一个错误。

主持人应排除www。

<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="myapp.example.com"
                    android:scheme="http" />

            </intent-filter>