下拉菜单(选择标签、组合框)在 GeckoView 实现中不起作用

2024-02-20

我正在 Android 应用程序内实现 Geckoview 实例。一切看起来都工作正常,Geckoview 能够加载 URL。 我的问题是,如果网站有下拉菜单(选择标签、组合框),当我单击箭头时,选项不会出现。

我尝试过使用不同版本和渠道的存储库(每晚、发布、测试版),但仍然遇到同样的问题。

我已经在不同的设备和 Android 版本上进行了尝试。

当我使用使用 Geckoview 的浏览器(参考浏览器、Firefox 预览版)时,“下拉菜单”工作得很好,所以我认为这是我的 Geckoview 实现中的配置问题。

GeckoView geckoview;
GeckoSession session;
GeckoRuntime runtime;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    geckoview = findViewById(R.id.geckoviewer);
    session = new GeckoSession();

    session.getSettings().setAllowJavascript(true);
    session.getSettings().setDisplayMode(GeckoSessionSettings.DISPLAY_MODE_FULLSCREEN);
    session.getSettings().setUserAgentMode(GeckoSessionSettings.USER_AGENT_MODE_MOBILE);

    GeckoRuntimeSettings.Builder builder = new GeckoRuntimeSettings.Builder()
            .javaScriptEnabled(true)

            .consoleOutput(true);

    runtime = GeckoRuntime.create(this, builder.build());

    session.open(runtime);

原因是 GeckoView 没有为此提供默认实现。你需要实施PromptDelegate(在这种情况下onChoicePrompt()).

请参阅 API 文档:https://mozilla.github.io/geckoview/javadoc/mozilla-central/org/mozilla/geckoview/GeckoSession.PromptDelegate.html https://mozilla.github.io/geckoview/javadoc/mozilla-central/org/mozilla/geckoview/GeckoSession.PromptDelegate.html

参考浏览器和 Firefox Preview 使用的是 Mozilla 的“Android Components”项目的实现。feature-prompts组件实现所有这些提示:https://github.com/mozilla-mobile/android-components/tree/master/components/feature/prompts https://github.com/mozilla-mobile/android-components/tree/master/components/feature/prompts

“GeckoView 示例应用程序”使用另一个实现,您可以在此处找到该代码:https://searchfox.org/mozilla-central/source/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/BasicGeckoViewPrompt.java https://searchfox.org/mozilla-central/source/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/BasicGeckoViewPrompt.java

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

下拉菜单(选择标签、组合框)在 GeckoView 实现中不起作用 的相关文章