Convert Figma logo to code with AI

Justson logoAgentWeb

AgentWeb is a powerful library based on Android WebView.

9,233
1,635
9,233
79

Top Related Projects

11,811

VasSonic is a lightweight and high-performance Hybrid framework developed by tencent VAS team, which is intended to speed up the first screen of websites working on Android and iOS platform.

4,867

🚀Optimizer for mobile applications

17,130

Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstall apk.

8,125

A powerful Android Dynamic Component Framework.

4,412

Robust is an Android HotFix solution with high compatibility and high stability. Robust can fix bugs immediately without a reboot.

🔥 A low-cost Android screen adaptation solution (今日头条屏幕适配方案终极版,一个极低成本的 Android 屏幕适配方案).

Quick Overview

AgentWeb is an Android WebView library that simplifies the integration of WebViews into Android applications. It provides a powerful and flexible way to handle web content within native apps, offering features like file uploading, JavaScript interfaces, and enhanced security.

Pros

  • Easy integration with minimal setup required
  • Comprehensive set of features for handling web content
  • Built-in security measures and performance optimizations
  • Extensive documentation and active community support

Cons

  • Limited customization options for advanced use cases
  • Potential overhead for simple WebView implementations
  • Dependency on third-party library may increase app size
  • Learning curve for developers new to WebView concepts

Code Examples

  1. Basic WebView setup:
AgentWeb.with(this)
    .setAgentWebParent(container, LinearLayout.LayoutParams(-1, -1))
    .useDefaultIndicator()
    .createAgentWeb()
    .ready()
    .go("https://www.example.com")
  1. Handling file uploads:
AgentWeb.with(this)
    .setAgentWebParent(container, LinearLayout.LayoutParams(-1, -1))
    .useDefaultIndicator()
    .setOpenOtherPageWays(DefaultWebClient.OpenOtherPageWays.ASK)
    .setPermissionInterceptor(PermissionInterceptor { url, permissions, action ->
        // Handle permissions
        false
    })
    .createAgentWeb()
    .ready()
    .go("https://www.example.com")
  1. Adding JavaScript interface:
class JsInterface {
    @JavascriptInterface
    fun showToast(message: String) {
        Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
    }
}

AgentWeb.with(this)
    .setAgentWebParent(container, LinearLayout.LayoutParams(-1, -1))
    .useDefaultIndicator()
    .setJavaObject("android", JsInterface())
    .createAgentWeb()
    .ready()
    .go("https://www.example.com")

Getting Started

To use AgentWeb in your Android project:

  1. Add the dependency to your app's build.gradle file:
dependencies {
    implementation 'com.just.agentweb:agentweb:4.1.4'
}
  1. In your Activity or Fragment, initialize AgentWeb:
class MainActivity : AppCompatActivity() {
    private var mAgentWeb: AgentWeb? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        mAgentWeb = AgentWeb.with(this)
            .setAgentWebParent(container, LinearLayout.LayoutParams(-1, -1))
            .useDefaultIndicator()
            .createAgentWeb()
            .ready()
            .go("https://www.example.com")
    }

    override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
        return if (mAgentWeb?.handleKeyEvent(keyCode, event) == true) {
            true
        } else {
            super.onKeyDown(keyCode, event)
        }
    }
}

This setup provides a basic implementation of AgentWeb in your Android application.

Competitor Comparisons

11,811

VasSonic is a lightweight and high-performance Hybrid framework developed by tencent VAS team, which is intended to speed up the first screen of websites working on Android and iOS platform.

Pros of VasSonic

  • Focuses on optimizing web page loading speed, particularly for mobile devices
  • Implements a hybrid architecture combining native and web technologies
  • Provides a more comprehensive solution for web acceleration and optimization

Cons of VasSonic

  • More complex implementation compared to AgentWeb
  • Requires additional setup and configuration for optimal performance
  • May have a steeper learning curve for developers new to hybrid web technologies

Code Comparison

VasSonic:

SonicSession session = SonicEngine.getInstance().createSession(url, null);
if (null != session) {
    session.bindClient(new SonicSessionClientImpl());
}

AgentWeb:

AgentWeb.with(this)
    .setAgentWebParent(mLinearLayout, new LinearLayout.LayoutParams(-1, -1))
    .useDefaultIndicator()
    .createAgentWeb()
    .ready()
    .go(url);

VasSonic focuses on optimizing web page loading speed through a hybrid architecture, while AgentWeb provides a simpler and more straightforward approach to integrating WebView functionality in Android applications. VasSonic offers more advanced features for web acceleration but requires more setup, while AgentWeb is easier to implement but may not provide the same level of optimization for mobile web experiences.

4,867

🚀Optimizer for mobile applications

Pros of Booster

  • Focuses on app performance optimization and build speed improvement
  • Provides a comprehensive suite of tools for Android app development
  • Offers features like resource compression, multithreading, and code obfuscation

Cons of Booster

  • More complex setup and configuration compared to AgentWeb
  • Primarily targets Android app optimization, less versatile for web-related tasks
  • Steeper learning curve for developers new to performance optimization

Code Comparison

AgentWeb (JavaScript interface):

@JavascriptInterface
public void callAndroid(String msg) {
    Log.i("Info", "JS call Android: " + msg);
}

Booster (Performance optimization):

@Transformer
class SampleTransformer : ClassTransformer {
    override fun transform(context: TransformContext, klass: ClassNode): ClassNode {
        // Optimize class here
        return klass
    }
}

Summary

AgentWeb is a lightweight, easy-to-use WebView component for Android, focusing on simplifying web integration in Android apps. Booster, on the other hand, is a comprehensive performance optimization toolkit for Android app development, offering a wide range of features to improve app performance and build speed. While AgentWeb excels in web-related tasks, Booster provides more advanced optimization capabilities for overall Android app development.

17,130

Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstall apk.

Pros of Tinker

  • Robust hot-fix solution for Android apps, allowing dynamic patching without reinstallation
  • Backed by Tencent, ensuring ongoing support and updates
  • Extensive documentation and community support

Cons of Tinker

  • More complex setup and integration compared to AgentWeb
  • Primarily focused on hot-fixing, while AgentWeb offers broader web-related functionality
  • Steeper learning curve for developers new to hot-fix solutions

Code Comparison

AgentWeb (JavaScript interface):

@JavascriptInterface
public void callAndroid(String msg) {
    // Handle JavaScript call
}

Tinker (applying a patch):

TinkerInstaller.onReceiveUpgradePatch(getApplicationContext(), patchPath);

Key Differences

  • Purpose: AgentWeb is a lightweight web container for Android, while Tinker is a hot-fix solution
  • Functionality: AgentWeb focuses on web-related features, Tinker on dynamic patching
  • Integration: AgentWeb is generally easier to integrate for basic web functionality
  • Use cases: AgentWeb is ideal for web-based apps, Tinker for maintaining and updating live apps

Both projects serve different purposes and can be complementary in an Android development ecosystem. The choice between them depends on the specific needs of the project, with AgentWeb being more suitable for web-centric applications and Tinker for apps requiring frequent updates without reinstallation.

8,125

A powerful Android Dynamic Component Framework.

Pros of Atlas

  • Comprehensive dynamic component framework for large-scale Android apps
  • Supports dynamic deployment and real-time updates without app reinstallation
  • Provides advanced features like multi-dex support and resource isolation

Cons of Atlas

  • Steeper learning curve due to its complex architecture
  • Requires more setup and configuration compared to AgentWeb
  • May be overkill for smaller projects or simple web-based applications

Code Comparison

Atlas (Component declaration):

@AtlasBundle(coverageExt = "so")
public class BundleA extends AtlasBundleImpl {
    // Bundle implementation
}

AgentWeb (WebView initialization):

AgentWeb.with(this)
    .setAgentWebParent(mLinearLayout, new LinearLayout.LayoutParams(-1, -1))
    .useDefaultIndicator()
    .createAgentWeb()
    .ready()
    .go("http://www.jd.com");

Atlas focuses on modular app development and dynamic updates, while AgentWeb simplifies WebView integration and management. Atlas is better suited for large-scale, complex Android applications that require flexibility and scalability. AgentWeb is ideal for projects that primarily need efficient web content display and interaction within native Android apps.

Atlas offers more advanced features but requires more setup, while AgentWeb provides a simpler, more straightforward solution for web-based functionality in Android applications. The choice between the two depends on the project's scale, complexity, and specific requirements.

4,412

Robust is an Android HotFix solution with high compatibility and high stability. Robust can fix bugs immediately without a reboot.

Pros of Robust

  • Focuses on app stability and crash prevention
  • Provides a comprehensive solution for handling various runtime exceptions
  • Offers a plugin system for customization and extensibility

Cons of Robust

  • Primarily designed for Java-based Android development
  • May introduce additional complexity to the codebase
  • Requires more setup and configuration compared to AgentWeb

Code Comparison

Robust:

@Modify
public String modifiedMethod(String input) {
    // Method implementation
}

AgentWeb:

AgentWeb.with(this)
    .setAgentWebParent(mLinearLayout, new LinearLayout.LayoutParams(-1, -1))
    .useDefaultIndicator()
    .createAgentWeb()
    .ready()
    .go("https://www.example.com");

Robust focuses on method modification and exception handling, while AgentWeb provides a fluent API for web view integration. Robust is more suited for improving app stability, whereas AgentWeb simplifies web view implementation in Android apps.

Robust offers a broader scope of application stability improvements, but requires more setup and understanding of its annotation-based system. AgentWeb, on the other hand, provides a more straightforward solution for web view integration with less configuration overhead.

🔥 A low-cost Android screen adaptation solution (今日头条屏幕适配方案终极版,一个极低成本的 Android 屏幕适配方案).

Pros of AndroidAutoSize

  • Focuses specifically on screen adaptation and UI scaling
  • Provides a more comprehensive solution for handling different screen sizes and densities
  • Offers flexible configuration options for customizing scaling behavior

Cons of AndroidAutoSize

  • Limited to UI scaling and doesn't provide broader web functionality
  • May require more setup and configuration for basic screen adaptation tasks
  • Less actively maintained compared to AgentWeb (last update over 2 years ago)

Code Comparison

AndroidAutoSize:

AutoSizeConfig.getInstance().setCustomFragment(true).setBaseOnWidth(false)
    .setExcludeFontScale(true).setUseDeviceSize(true);

AgentWeb:

AgentWeb.with(this)
    .setAgentWebParent(mLinearLayout, new LinearLayout.LayoutParams(-1, -1))
    .useDefaultIndicator()
    .createAgentWeb()
    .ready()
    .go("http://www.jd.com");

While AndroidAutoSize focuses on screen adaptation with detailed configuration options, AgentWeb provides a more comprehensive web-based solution with simpler setup for basic web functionality. AndroidAutoSize is better suited for projects requiring precise UI scaling across various devices, while AgentWeb is more appropriate for applications needing integrated web capabilities.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

AgentWeb 介绍

AgentWeb 是一个基于的 Android WebView ,极度容易使用以及功能强大的库,提供了 Android WebView 一系列的问题解决方案 ,并且轻量和极度灵活,详细使用请参照上面的 Sample 。

Gradle 引入

allprojects {
  repositories {
    mavenCentral()
    maven { url 'https://jitpack.io' }
  }
}
  • Androidx

     implementation 'io.github.justson:agentweb-core:v5.1.1-androidx' 
     implementation 'io.github.justson:agentweb-filechooser:v5.1.1-androidx' // (可选)
     implementation 'com.github.Justson:Downloader:v5.0.4-androidx' // (可选)
    
    

相关

注意事项

  • 支付宝使用需要引入支付宝SDK ,并在项目中依赖 , 微信支付不需要做任何操作。
  • AgentWeb 内部使用了 AlertDialog 需要依赖 AppCompat 主题 。
  • setAgentWebParent 不支持 ConstraintLayout 。
  • mAgentWeb.getWebLifeCycle().onPause();会暂停应用内所有WebView 。
  • minSdkVersion 低于等于16以下自定义WebView请注意与 JS 之间通信安全。

文档帮助

有问题或者有更好的建议

赞赏

开源不易,你的支持是我更新的动力。

License

License

Copyright (C)  Justson(https://github.com/Justson/AgentWeb)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

​

​