Open an html page in chrome browser

3.5k Views Asked by At

How to open an html page which is located in my application data in chrome browser? For default browser i am using following code -

Intent browserIntent = new Intent(Intent.ACTION_VIEW);
            browserIntent.setData(Uri.fromFile(file));
             browserIntent.setType("text/html");
            browserIntent.setClassName("com.android.browser",
             "com.android.browser.BrowserActivity");
             browserIntent.addCategory(Intent.CATEGORY_BROWSABLE);
             browserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            browserIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
         browserIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
            startActivity(browserIntent);

But this code does not work on chrome browser. How can i open same html page in chrome browser.

Thanks in advance

1

There are 1 best solutions below

2
On

You can't specify which browser the user shoud use. Your code is right. Then a little Dialog will be shown to the user where the user can select one of the installed browsers. If you don't get this dialog then you have saved your selection to use it always.