All Projects → lqiz → Andorid Litehybrid Webview

lqiz / Andorid Litehybrid Webview

A android hybrid framework, works for H5 and native interactions via webview.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Andorid Litehybrid Webview

Vassonic
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.
Stars: ✭ 11,466 (+29300%)
Mutual labels:  hybrid, webview
Hybridfoundation
混合应用基础架构 跨平台热更新方案 Js双向通信 基础WebView
Stars: ✭ 164 (+320.51%)
Mutual labels:  hybrid, webview
Agentweb
AgentWeb is a powerful library based on Android WebView.
Stars: ✭ 8,375 (+21374.36%)
Mutual labels:  hybrid, webview
React Native Turbolinks
React Native adapter for building hybrid apps with Turbolinks 5
Stars: ✭ 177 (+353.85%)
Mutual labels:  hybrid, webview
RobustWebView
Android WebView H5 秒开方案总结
Stars: ✭ 38 (-2.56%)
Mutual labels:  webview, hybrid
Aachartcore
📈📊☕️☕️☕️An elegant modern declarative data visualization chart framework for Android. Extremely powerful, supports line, spline, area, areaspline, column, bar, pie, scatter, angular gauges, arearange, areasplinerange, columnrange, bubble, box plot, error bars, funnel, waterfall and polar chart types.极其精美而又强大的 Android 数据可视化图表框架,支持柱状图、条形图、折线图、曲线图、折线填充图、曲线填充图、气泡图、扇形图、环形图、散点图、雷达图、混合图等各种类型的多达几十种的信息图图表,完全满足工作所需.
Stars: ✭ 424 (+987.18%)
Mutual labels:  hybrid, webview
Easybridge
A design of easy js-bridge which provide the ability to communicate between java and javascript.It is based on the android webview's feature [addJavaScriptInterface]
Stars: ✭ 158 (+305.13%)
Mutual labels:  hybrid, webview
React Native Webview Invoke
Invoke functions between React Native and WebView
Stars: ✭ 211 (+441.03%)
Mutual labels:  hybrid, webview
Hybrid-Web-Platform
Full-fledged WebView as Xamarin.Forms plugin with cross-platform C# to JavaScript and JavaScript to C# calls support. Eventually invented for painless hybrid apps creation.
Stars: ✭ 19 (-51.28%)
Mutual labels:  webview, hybrid
Aachartcore Kotlin
📈📊⛰⛰⛰An elegant modern declarative data visualization chart framework for Android . Extremely powerful, supports line, spline, area, areaspline, column, bar, pie, scatter, angular gauges, arearange, areasplinerange, columnrange, bubble, box plot, error bars, funnel, waterfall and polar chart types.极其精美而又强大的 Android 数据可视化图表框架,支持柱状图、条形图、折线图、曲线图、折线填充图、曲线填充图、气泡图、扇形图、环形图、散点图、雷达图、混合图等各种类型的多达几十种的信息图图表,完全满足工作所需.
Stars: ✭ 332 (+751.28%)
Mutual labels:  hybrid, webview
Aachartkit
📈📊🚀🚀🚀An elegant modern declarative data visualization chart framework for iOS, iPadOS and macOS. Extremely powerful, supports line, spline, area, areaspline, column, bar, pie, scatter, angular gauges, arearange, areasplinerange, columnrange, bubble, box plot, error bars, funnel, waterfall and polar chart types. 极其精美而又强大的跨平台数据可视化图表框架,支持柱状图、条形图、折…
Stars: ✭ 4,358 (+11074.36%)
Mutual labels:  hybrid, webview
Hybrid
A framework for building apps with hybrid.
Stars: ✭ 15 (-61.54%)
Mutual labels:  hybrid
Jxbwkwebview
An component WebView for iOS base on WKWebView
Stars: ✭ 646 (+1556.41%)
Mutual labels:  webview
React Native Wkwebview
WKWebview Component for React Native
Stars: ✭ 622 (+1494.87%)
Mutual labels:  webview
Jsbridge
A simpler, extendable bidirectional communication Frame between Android WebView and Javascript
Stars: ✭ 612 (+1469.23%)
Mutual labels:  webview
Popup Bridge Android
PopupBridge allows WebViews to open popup windows in a browser and send data back to the WebView
Stars: ✭ 31 (-20.51%)
Mutual labels:  webview
Wkwebviewjavascriptbridge
🌉 A Bridge for Sending Messages between Swift and JavaScript in WKWebViews.
Stars: ✭ 863 (+2112.82%)
Mutual labels:  hybrid
Luna Studio
Looking for Luna, the WYSIWYG language for data processing? Development has moved 👉
Stars: ✭ 602 (+1443.59%)
Mutual labels:  hybrid
Android Reports And Resources
A big list of Android Hackerone disclosed reports and other resources.
Stars: ✭ 590 (+1412.82%)
Mutual labels:  webview
Mui Kidapp
基于 MUI 构建一个具有 90 +页面的APP应用
Stars: ✭ 551 (+1312.82%)
Mutual labels:  hybrid

轻量级 H5 Native Hybrid 框架

轻量级litehybrid框架适合适合大多数 app 的 H5 Native 交互的,交互原理较为简单。 GIT 地址:LiteHybrid。其代码分两部分,litehybird 为框架代码。 主工程 为示例代码,

####原理:

1. 封装原生 webview,使用 WebViewClient 与 WebChromeClient
2. H5 调用 Native 采用 js prompt 方式
3. Native 调用 H5 采用 loadurl API

####使用说明:

  1. errorview 和 loadingview 可以自定义

  2. 对 WebView 设置可以通过 LHPreferences传递,如 agent等

  3. 通过INVOKE注解,来使H5调用相应Native函数,参见INVOKE类,结构合理。

####使用方式:

其中,H5调用 native,以 JSONObject 方式传递调用信息,格式约定如下:

{
  "invoke": "ANNOTATION_METHOD" 
  "paras": JSONObject
}

其中,"invoke" 值为字符串,对应调用方法,如下文中 popToast"paras" 为对应参数信息,参数内容约定为 JSONObject.

“ANNOTATION_METHOD” 声明如下,参见 WebViewActivity 里的 Invoker1:

@INVOKE("popToast")
public void popToast(JSONObject msgObj) {
...
}

注意事项:

1. 方法为 public,否则会有 IllegalAccessException
2. 方法约定一个参数,JSONObject paras,为H5 传递来 paras 值
3. 方法 @INVOKE("popToast") 注解中的 popToast等字段,对应 H5 传递来的 XXX_METHOD,采用字符串对比方式定位应该调用函数。

H5调用NA调试

请在handleJsPrompt 处设置断点,查看H5 返回值,并进入函数体调试,看json解析是否抛出异常。

    @Override
    public boolean onJsPrompt(WebView view, String origin,
                              String message, String defaultValue,
                              final JsPromptResult result) {
        try {
            parentEngine.handleJsPrompt(message);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        result.confirm();
        return true;
    }

NA调用JS调试

在 WebViewActivity 里参考 javascript:window.changeBackground('red')

H5页面加载过程中的状态处理

webview 通过WebViewClient 处理H5页面加载过程中的状态,页面加载时候, WebviewClient 给出的回调调用顺序不同,通常使用的三种回调分析如下:

正常情况下 onPageStarted -> onPageFinished

失败情况下: onPageStarted -> onReceivedError -> onPageFinished

超时情况下: onPageStarted -> 30s-> onReceivedError -> onPageFinished

加载过程中重试: onPageStarted -> 重试-> onPageFinished -> onPageStarted

#####H5内JS的回调处理 webview 通过 WebChromeClient处理 H5 内js的回调,本框架使用了onJsPrompt方式,其他还有alert方式等。

其他 webview 使用经验

  1. webview 在被销毁后,litehybrid的 LHWebView 中有标志位标志进行判断,因为webview销毁后并不立即为空,再调用可能会引发异常。此处同Android SDK中的的 webviewfragment处理一致。

  2. 提前超时:提前超时时,使用了 loadurl("about:blank") 进行清除缓存,但loadurl("about:blank") 会重新执行 webview 的生命周期,LHWebViewClient 有标志位进行处理。

  3. 账户信息应当采用诸如cookie方式注入提取,example中未体现。

  4. webview onPagefinished 后,js 不一定完全加载成功。最好方式是用JS的回调通知native调用H5内js时机准备好。

PRFSC, 不好的地方指出来相互学习

QQ 群:77157252

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].