Skip to the content.

ByWebView agent guide

For agents integrating this library into Android View-based apps or working in this repository. An agent operating in another repository does not automatically load this file: fetch and read it explicitly. The guidance below is based on the 1.2.2 tag; examples have not been built or run for this documentation update.

Scope and version

Integration workflow

  1. Inspect the consuming project’s repository configuration, Android/Gradle versions, Activity/Fragment lifecycle, existing WebView and URL policy. Decide whether this library fits; do not silently replace an existing WebView client or security policy.
  2. Add JitPack in the project’s actual repository configuration. Example for settings.gradle: dependencyResolutionManagement { repositories { google(); mavenCentral(); maven { url 'https://jitpack.io' } } }. Kotlin DSL: maven { url = uri("https://jitpack.io") }. For older builds use the existing root allprojects.repositories.
  3. Add implementation 'com.github.youlookwhat:ByWebView:1.2.2' to the consuming module, and a compatible com.google.android.material:material dependency if it is not already provided. The library manifest declares INTERNET and ACCESS_NETWORK_STATE.
  4. Create with ByWebView.with(activity).setWebParent(container, layoutParams). A parent and matching ViewGroup.LayoutParams are required. Use .get() to obtain the wrapper without loading, configure its getWebView().getSettings(), then call loadUrl(url). Alternatively, .loadUrl(url) builds and loads immediately; do not use that form if settings must be changed before loading.
  5. Forward lifecycle appropriately: onResume(), onPause(), and onDestroy() when the owning view is destroyed. onPause() and onResume() call WebView’s process-wide pauseTimers() and resumeTimers(), so consider other WebViews in the app. In a Fragment, use view lifecycle and do not retain the Activity or WebView after onDestroyView.
  6. Route back navigation through handleKeyEvent(keyCode, event) or isBack() before the Activity/Fragment’s normal back behavior. It exits full-screen video first, then goes back in WebView history. Verify behavior with the app’s existing back dispatcher.
  7. If image upload is required, forward Activity onActivityResult(requestCode, resultCode, data) to handleFileChooser(...). The bundled chooser uses legacy startActivityForResult, selects image/* and handles the returned URI; it is not a general file chooser or a camera implementation. Test success and cancellation on supported devices.

See README_EN.md for a complete Java Activity example. In the target project use real resources and data, compile and exercise the flow; do not treat documentation examples as proof of compatibility.

Security and navigation

API reference

Validation and release limitations

Version 1.2.2 uses an older build configuration and contains WebSettings.setAppCacheEnabled; the newer default branch comments this call out. The current Android SDK/Gradle and JitPack resolution may not work with the old release. Build the actual consuming project and report resolution or compilation failures; do not imply that an unreleased fix is present in 1.2.2.

Validate page loading and main-frame failures, SSL cancellation, allowed and rejected URLs, history/back navigation, and Activity/Fragment cleanup. If used, also test image chooser selection/cancellation, JS calls and bridge restrictions, full-screen entry/exit and orientation, and behavior on supported Android versions. Do not report unperformed checks as passing.

Repository

:ByWebView contains the library; :app contains examples. Useful references: app/src/main/java/com/example/jingbin/webviewstudy/ui/ByWebViewActivity.java, library source under ByWebView/src/main/java/me/jingbin/web/, and release notes. Read the tag being integrated before using an API from the default branch. The Gradle wrapper is ./gradlew; Android SDK and compatible tooling are required.