I'm trying to send intent to browser to open local file. I wish to use default browser to open this file.
if(file.exists()){
Log.d(TAG, "file.exists");
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.fromFile(file));
context.startActivity(intent);
}
But it throws me and exeption
08-10 13:27:58.993: ERROR/AndroidRuntime(28453): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///sdcard/release_notes.htm }
If I use following intent browser opens google.com as expected
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://google.com"));
Also when I write the file url (file:///sdcard/release_notes.htm)
to browser address bar it opens it as expected.
To make certain file types OPEN on your computer, instead of Chrome Downloading... You have to download the file type once, then right after that download, look at the status bar at the bottom of the browser. Click the arrow next to that file and choose "always open files of this type". DONE.
How to Open Local Files on Your Browser in Windows 1 Preamble – Security Issues. There are a few issues that need to be addressed before you access local files in your browser. ... 2 Google Chrome. Using Google Chrome to access local files is as easy as pressing Ctrl + O at the same time. ... 3 Firefox. ... 4 Edge. ... 5 Wrapping Up. ...
To add the Local Explorer extension to a Chromium browser, which enhances the file navigator, click the Add to Chrome button on that add-on’s page. Press the Add extension button to confirm. Thereafter, a Local Explorer page will open on which you’ll need to click the Add to Windows Explorer button.
Using Google Chrome to access local files is as easy as pressing Ctrl + O at the same time. This interface will open, allowing you to navigate to whichever file or folder is needed.
Depending on the browser, opening the local files is either natively supported or requires a slight modification of the settings on your computer. There are a few issues that need to be addressed before you access local files in your browser. Since the browser has complete access to the Internet, security is the most important.
The browser is started only for HTML and other compatible files. this should work:
Intent intent = new Intent(ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "text/html");
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