【问题标题】:Android custom scheme not working on some devicesAndroid自定义方案不适用于某些设备
【发布时间】:2011-07-08 15:19:22
【问题描述】:

我通过将其添加到我在 android 清单中的活动中为我的应用制定了自定义方案:

 <activity android:name=".TabHostActivity"
              android:label="@string/app_name"
               android:configChanges="orientation|keyboardHidden">
        <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.action.DEFAULT" />
                 <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.LAUNCHER" />
                 <data  android:scheme="myscheme" />
        </intent-filter>
    </activity>

当我在 android 浏览器中写入“myscheme://”时,它会打开我的应用程序(在某些设备上)。问题是这不适用于三星galaxy s和Xperia play。它只在 google 上搜索 myscheme://。

有人知道这里有什么问题吗?

任何帮助将不胜感激:)

【问题讨论】:

  • 这种情况是在工作设备和非工作设备(例如 Chrome)上使用同一个浏览器,还是在所有设备上使用普通浏览器?听起来这些设备的默认浏览器并没有达到您的预期。您也可以尝试运行adb -d shell am start -d myscheme://something -a android.intent.action.VIEW 以确保在您不使用浏览器时在设备上正确处理意图。
  • 我认为没什么问题...您可以按照 Tanis.7x 所说的进行验证,或者使用 制作一个虚拟网页
  • 您可以尝试从指定您的自定义方案的意图过滤器中删除LAUNCHER 类别并重试吗?我之前使用过自定义方案,声明中的唯一区别就是这个。此外,文档规定在 Intent 解析期间必须匹配所有类别。

标签: android manifest browsable


【解决方案1】:

浏览器通常会搜索一个术语或在其前面添加“http://”(如果它尚不存在)。我的猜测是这就是这里发生的事情。

如果您创建一个带有指向 myscheme://something 的链接的 HTML 页面,您的应用应该会显示在选择器列表中。

类似这样的: &lt;a href="myscheme://it_worked"&gt; click this link &lt;/a&gt;

【讨论】:

    猜你喜欢
    • 2021-06-01
    • 2023-01-18
    • 2016-10-11
    • 2018-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-10
    相关资源
    最近更新 更多