更新时间:2023-10-11 19:57:40
源代码:
//打开新的隐身标签目前仅限于Chrome或第一方。
if(!isInternal
&& IntentUtils.safeGetBooleanExtra(
intent,EXTRA_OPEN_NEW_INCOGNITO_TAB,false)){
return true;
}
看起来额外的东西除了分叉Chrome或明确允许由谷歌。
I have spent much time on this and unable to figured out about this.
I need to launch chrome browser in incognito mode.
My Code:
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);
}
}
i found several posts on this but am unable to find the solution. here
This link gives me some idea about incognito mode but i tried this also.
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);
}
}
But chrome browser is not receiving any intent info from app. can any one help me where am wrong and what to do?
From the source code :
// "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;
}
It seems the extra will do nothing unless you are forking Chrome or explicitly allowed to by Google.