Currently I put my html file in assets, and I load it in WebView. Can I load it through chrome custom tab?
Adding Local Explorer to Chrome is a two-part process. You need the add-on in Chrome, and you need an integration module to run the default programs for the files. Open the Local Explorer extension page in the Chrome Web Store, click Add to Chrome in the upper-right corner. In the popup window, select Add extension.
How to start a local web server to view HTML files. open up the terminal or command prompt. navigate to the directory where the files live. run a local python server by running: python3 -m http.server 1234. Go to http://localhost:1234/ in your browser and navigate to or type into the address bar the ...
Open your Terminal and paste in the file path to the Chrome executable you just copied If it's not recognizing the path, the spaces in the file path might need to be escaped with a forward-slash like Google\ Chrome.app Add the following flag to the end of your command: --allow-file-access-from-files
Everyone knows that you can use Google Chrome to browse websites. But like any browser, you can also use it to browse folders and files on your local device, just like Windows Explorer in Windows and Finder in macOS.
No, it is not possible to open file:// URLs in customtabs.
Actually there is a way. in AndroidManifest.xml
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
define provider paths
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path
name="external_files"
path="." />
</paths>
And then just extract your local file to external dir
val file = File(activity.externalCacheDir, "hello.html")
val bytes = resources.openRawResource(R.raw.hello).use { it.readBytes() }
FileOutputStream(file).use { it.write(bytes) }
val uri = FileProvider.getUriForFile(activity, "${activity.packageName}.provider", file)
CustomTabsIntent.Builder()
.build()
.also { it.intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) }
.launchUrl(activity, uri)
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