【问题标题】:Intent filter to open my application when a specific URL is called is not working调用特定 URL 时打开我的应用程序的意图过滤器不起作用
【发布时间】:2014-02-20 01:05:37
【问题描述】:

如果打开某个 URL,无论是通过扫描的 QR 码、电子邮件中的链接还是从 Chrome 或浏览器浏览到该网站,我都尝试使用意图过滤器打开我的活动。这是我的 Manifest 中的一个 sn-p:

 <activity
        android:name="com.openapp.projecttest.Main"
        android:label="@string/app_name" >
        <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"></action>
            <category android:name="android.intent.category.DEFAULT"></category>
            <category android:name="android.intent.category.BROWSABLE"></category>
            <data android:host="www.qwert.com" android:scheme="http"></data> 
        </intent-filter> 
    </activity>

当我在谷歌浏览器上浏览它时,它似乎没有触发意图过滤器。我是否缺少权限?

【问题讨论】:

  • 您使用的 URL 中是否包含路径?像 www.qwert.com/somePath
  • 您能否提供一个您尝试触发过滤器的 URL 示例?
  • 它不适用于任何 URL,但我意识到它现在可以通过链接工作,但如果我通过浏览器浏览到 URL 则无法工作

标签: android android-intent android-manifest intentfilter


【解决方案1】:

它可以通过链接起作用,但如果通过浏览器浏览到 URL 则不起作用。

【讨论】:

    【解决方案2】:

    如果您在数据过滤器中包含 pathPattern,它应该可以通过浏览器链接工作。

    android:pathPattern="/path/pattern"
    

    当然是在哪里填写路径和模式。

    【讨论】:

    • 它确实可以通过链接工作,如果您通过浏览器上的 URL 浏览到链接,我有兴趣让它工作
    猜你喜欢
    • 2012-10-28
    • 2013-10-03
    • 2012-01-07
    • 2013-03-15
    • 1970-01-01
    • 1970-01-01
    • 2020-03-23
    • 1970-01-01
    • 2013-11-20
    相关资源
    最近更新 更多