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?
You can also use a keyboard shortcut to open an Incognito window: Windows, Linux, or Chrome OS: Press Ctrl + Shift + n. Mac: Press ⌘ + Shift + n.
To do so, tap and hold on the Chrome icon from the home screen or your device's app drawer. This will open an overlay menu, then, tap and hold the 'New Incognito tab' tile and drag it across your screen.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With