gpt4 book ai didi

java - 如何从 Android 应用程序在谷歌浏览器中打开网页隐身

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:04:42 25 4
gpt4 key购买 nike

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

我需要以隐身模式启动 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 浏览器没有收到来自应用程序的任何 Intent 信息。任何人都可以帮助我哪里错了以及该怎么做吗?

最佳答案

来自源代码:

// "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;
}

除非您 fork Chrome 或 Google 明确允许,否则额外内容似乎什么也做不了。

关于java - 如何从 Android 应用程序在谷歌浏览器中打开网页隐身,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37696033/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com