How to open a web page in Google chrome incognito from android app
<p>I have spent much time on this and unable to figured out about this.</p>

<p>I need to launch chrome browser in incognito mode.</p>

<p>My Code: </p>

<pre><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);
    }
}
</code></pre>

<p>i found several posts on this but am unable to find the solution.
<a href="https://stackoverflow.com/questions/8127654/can-my-android-app-open-a-url-in-an-incognito-tab">here</a></p>

<p>This <a href="https://chromium.googlesource.com/chromium/src/+/3812747c8aaaa5e9aeb370442c1c8cdc2483b9a0/chrome/android/java/src/org/chromium/chrome/browser/ServiceTabLauncher.java" rel="nofollow noreferrer">link</a> gives me some idea about incognito mode but i tried this also.</p>

<pre><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");
    launchGoogleChrome.putExtra("com.android.chrome.EXTRA_OPEN_NEW_INCOGNITO_TAB", true);
    try {
        startActivity(launchGoogleChrome);
    } catch (ActivityNotFoundException e) {
        launchGoogleChrome.setPackage(null);
        startActivity(launchGoogleChrome);
    }
}
</code></pre>

<p>But chrome browser is not receiving any intent info from app. can any one help me where am wrong and what to do?</p>