agentweb回到首页_Android 使用AgentWeb加载h5页面,并互调方法

本文介绍了如何在Android应用中使用AgentWeb加载H5页面,并实现H5与Android之间的方法互调。通过引入AgentWeb库,设置WebChromeClient和WebViewClient,以及创建AndroidInterface类来处理JS调用Android的方法。同时,提供了Android调用H5方法的示例和页面刷新、加载新URL、清除缓存等操作。
摘要由CSDN通过智能技术生成

https://github.com/Justson/AgentWeb

build.gradle(Moudle.app)androidx的引用

implementation 'com.just.agentweb:agentweb-androidx:4.1.4'

如果项目中h5需要选择图片或者是下载需要添加一下依赖

implementation 'com.just.agentweb:filechooser:4.1.4'// (可选)

implementation 'com.download.library:Downloader:4.1.4'// (可选)

如果添加选择图片或下载报错,需要添加一下配置build.gradle(Project:项目名称)

allprojects {

repositories {

...

maven { url "https://jitpack.io" }

}

}

布局的实现

android:orientation="vertical" android:layout_width="match_parent"

android:layout_height="match_parent">

//标题

layout="@layout/activity_left_title_text_view"/>

android:id="@+id/view"

android:orientation="vertical"

android:layout_width="match_parent"

android:layout_height="match_parent"/>

kotlin实现案例

import android.net.http.SslError

import android.os.Bundle

import android.view.KeyEvent

import android.view.View

import android.view.ViewGroup

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值