I have already considered this. onLoadRequest in NavigationDelegate gives me just the option to stop the loading.
But I need to return a WebResponse. Looks like I canât do it from onLoadRequest.
Scenario is to stop a load of an URL and return a (custom) WebResponse into GeckoView that might load a different page.
The code above could be updated to handle this scenario
just by using the session object to load the new URL.
private fun createNavigationDelegate(): GeckoSession.NavigationDelegate {
return object : GeckoSession.NavigationDelegate {
override fun onLoadRequest(session: GeckoSession, request: GeckoSession.NavigationDelegate.LoadRequest): GeckoResult<AllowOrDeny>? {
// Conditioning when the request should load.
return if (request.uri.contains("pattern")) {
GeckoResult.ALLOW
} else {
// Here is the trick :)
// load a new URL
geckoSession.loadUri("newURL")
// Cancels the actual load
GeckoResult.DENY
}
}
}
}
I have switched to GeckoView my Android application. Solves an issue I was facing playing Youtube videos on normal WebView. My concern is this: my APK file size raised from 2.5 MB to 162 MB after I have switched to GeckoView. Is this normal? How to keep the file size smaller?
Hi acrolink, I believe the size is that big because you are using a debug build, if you try with a release build the APK size must decrease significantly, if not please open an issue in the GeckoView Repo because this shouldnât be normal.
I am trying to download the file from the awesomeBrowser. Itâs failed to download the file. Can you add the how to handle the download and how can I see the request headers on any request?
@dhksrini The reason for that is that GeckoView does not provide a default implementation for that. You need to override GeckoSession.ContentDelegate (and in this case onExternalResponse() ).
Even for release build the size is big. Analyzing the APK shows that the major file contributing to the large size, for instance, when targeting armeabi-v7a is libxul.so (58.9 MB) in lib folder.