I spent a lot of time on it and could not understand about it.
I need to run the Chrome browser in incognito mode.
My code is:
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 about this, but could not find a solution. here
This link gives me some insight into incognito mode, but I tried it too.
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 the Chrome browser does not receive intent information from the application. can someone help me where am i wrong and what to do?
source share