AgentWeb:
? ? ? ? ? ? ? ? ? ? ?是一個(gè)高度封裝的Android WebView庫(kù)。具有簡(jiǎn)單易用,富有進(jìn)度條,支持文件上傳,下載,并且簡(jiǎn)化了javascript的通信等特點(diǎn)。
github地址 :
? ? ? ? ? ? ? ? ? ? ? https://github.com/Justson/AgentWeb
AgentWeb跟WebView的區(qū)別:

庫(kù)的使用:
引入: Gradle:compile 'com.just.agentweb:agentweb:1.0.3'
Activity用法:
mAgentWeb = AgentWeb.with(this) ? ?//傳入Activity
? ? .setAgentWebParent(mLinearLayout, new LinearLayout.LayoutParams(-1, -1)) ? ?//傳入AgentWeb 的父控件 ,如果父控件為 RelativeLayout , 那么第二參數(shù)需要傳入 RelativeLayout.LayoutParams
? ? .useDefaultIndicator() ? ? ? ? ? ? ? ? ? ? ?// 使用默認(rèn)進(jìn)度條
? ? .defaultProgressBarColor() ? ? ? ? ? ? // 使用默認(rèn)進(jìn)度條顏色
? ? .setReceivedTitleCallback(mCallback) ? ? ? ? ?//設(shè)置 Web 頁(yè)面的 title 回調(diào)
? ? .createAgentWeb()//
? ? .ready()
? ? .go("http://www.jd.com");
Fragment用法:
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
? ? super.onViewCreated(view, savedInstanceState);
? ? mAgentWeb = AgentWeb.with(this.getActivity(), this)//這里需要把 Activity 、 和 Fragment? 同時(shí)傳入
? ? .setAgentWebParent((ViewGroup) view, new LinearLayout.LayoutParams(-1, -1))// 設(shè)置 AgentWeb 的父控件 , 這里的view 是 LinearLayout , 那么需要傳入 LinearLayout.LayoutParams
? ? .useDefaultIndicator()// 使用默認(rèn)進(jìn)度條
? ? .setReceivedTitleCallback(mCallback) //標(biāo)題回調(diào)
? ? .setSecurityType(AgentWeb.SecurityType.strict) //注意這里開(kāi)啟 strict 模式 , 設(shè)備低于 4.2 情況下回把注入的 Js 全部清空掉 , 這里推薦使用 onJsPrompt 通信
? ? .createAgentWeb()//
? ? .ready()//
? ? .go(getUrl());
}