【问题标题】:How to open a web page in Google chrome incognito from android app如何从 android 应用程序以隐身方式在 Google chrome 中打开网页
【发布时间】:2016-10-08 08:09:36
【问题描述】:

我在这方面花了很多时间,但无法弄清楚。

我需要在隐身模式下启动 chrome 浏览器。

我的代码:

    private void launchBrowser() {
    String url = "http://foyr.com";
    Intent launchGoogleChrome = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    launchGoogleChrome.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    launchGoogleChrome.setPackage("com.android.chrome");
    try {
        startActivity(launchGoogleChrome);
    } catch (ActivityNotFoundException e) {
        launchGoogleChrome.setPackage(null);
        startActivity(launchGoogleChrome);
    }
}

我找到了几篇关于此的帖子,但找不到解决方案。 here

link 给了我一些关于隐身模式的想法,但我也尝试过。

    private void launchBrowser() {
    String url = "http://foyr.com";
    Intent launchGoogleChrome = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    launchGoogleChrome.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    launchGoogleChrome.setPackage("com.android.chrome");
    launchGoogleChrome.putExtra("com.android.chrome.EXTRA_OPEN_NEW_INCOGNITO_TAB", true);
    try {
        startActivity(launchGoogleChrome);
    } catch (ActivityNotFoundException e) {
        launchGoogleChrome.setPackage(null);
        startActivity(launchGoogleChrome);
    }
}

但是 chrome 浏览器没有收到来自应用的任何意图信息。任何人都可以帮助我哪里错了,该怎么办?

【问题讨论】:

  • 可能有使用 EXTRA_OPEN_NEW_INCOGNITO_TAB 的解决方案,但我认为从 chrome 外部是不可能的
  • 是的..是否有任何安卓意图导航到隐身模式?
  • 类似的问题早在几年前就已经发布了,甚至没有一位专家可以回答这些问题。我现在很好奇..也许根本没有解决方案。

标签: java android google-chrome


【解决方案1】:

来自源代码:

// "Open new incognito tab" is currently limited to Chrome or first parties.
if (!isInternal
        && IntentUtils.safeGetBooleanExtra(
                   intent, EXTRA_OPEN_NEW_INCOGNITO_TAB, false)) {
    return true;
}

除非你分叉 Chrome 或谷歌明确允许,否则额外的东西似乎什么都不做。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-10-12
    • 1970-01-01
    • 2023-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多