Top Related Projects
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.
🚀Optimizer for mobile applications
Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstall apk.
A powerful Android Dynamic Component Framework.
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
- Basic WebView setup:
AgentWeb.with(this)
.setAgentWebParent(container, LinearLayout.LayoutParams(-1, -1))
.useDefaultIndicator()
.createAgentWeb()
.ready()
.go("https://www.example.com")
- 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")
- 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:
- Add the dependency to your app's
build.gradle
file:
dependencies {
implementation 'com.just.agentweb:agentweb:4.1.4'
}
- 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
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.
🚀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.
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.
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.
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 designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
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
ä¹é´éä¿¡å®å ¨ã
æ档帮å©
- Wiki(ä¸å ¨)
Sample
(æ¨èï¼è¯¦ç»)- æ´æ°æ¥å¿
æé®é¢æè ææ´å¥½ç建议
- 欢è¿æ Issues
èµèµ
å¼æºä¸æï¼ä½ çæ¯ææ¯ææ´æ°çå¨åã
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.
â
â
Top Related Projects
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.
🚀Optimizer for mobile applications
Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstall apk.
A powerful Android Dynamic Component Framework.
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 屏幕适配方案).
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot