Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

WebView Quan Fang Mian Shi Yong ,JSJiao Hu , Jin Du Tiao , Shang Chuan Tu Pian , Cuo Wu Ye Mian , Shi Pin Quan Ping Bo Fang , Huan Qi Yuan Sheng App, Huo Qu Wang Ye Yuan Dai Ma , Bei Zuo Wei Di San Fang Liu Lan Qi Da Kai , DeepLink, [Teng Xun x5Shi Yong Shi Li ]

License

Notifications You must be signed in to change notification settings

youlookwhat/ByWebView

Repository files navigation

ByWebView

Features

  • Ji Ben Pei Zhi Shi Yong (Kuan Du Zi Gua Ying , Fan Hui Wang Ye Shang Yi Ceng , Xian Shi Wang Ye Biao Ti Deng )
  • Huan Qi San Fang Ying Yong (Bo Da Dian Hua , Fa Song Duan Xin , Fa Song You Jian Deng )
  • Shang Chuan Tu Pian (Ban Ben Jian Rong )
  • Cuo Wu Ye Mian Chu Li
  • Quan Ping Bo Fang Wang Luo Shi Pin
  • Yu JsJiao Hu Shi Li
  • You Ya De Jin Du Tiao Xian Shi Kong Jian

DemoShi Li :

  • DeepLinkDe Ji Ben Shi Yong
  • Bei Zuo Wei Di San Fang Liu Lan Qi Da Kai
  • Yu ToolBarLian Dong ,Zi Ding Yi WebView
  • Teng Xun x5Shi Yong Shi Li

Document

Screenshots

Download

Yin Yong

  1. Add the JitPack repository to your build file
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
  1. Add the dependency:
dependencies {
implementation 'com.github.youlookwhat:ByWebView:1.2.1'
}

Use

byWebView = ByWebView
.with(this)
.setWebParent(container, new LinearLayout.LayoutParams(-1, -1))
.useWebProgress(ContextCompat.getColor(this, R.color.coloRed))
.loadUrl(mUrl);

Yu JsJiao Hu

  • Diao Yong JsFang Fa :
// Wu Can Shu Diao Yong
byWebView.getLoadJsHolder().quickCallJs("javacalljs");
// Chuan Di Can Shu Diao Yong
byWebView.getLoadJsHolder().quickCallJs("javacalljswithargs", "androidChuan Ru Dao Wang Ye Li De Shu Ju ,You Can ");
  • JsDiao Yong JavaFang Fa :
ByWebView.with(this)
.addJavascriptInterface("injectedObject", new MyJavascriptInterface(this))
.loadUrl(mUrl);
window.injectedObject.startFunction()

Sheng Ming Zhou Qi Chu Li

@Override
protected void onPause() {
super.onPause();
byWebView.onPause();
}

@Override
protected void onResume() {
super.onResume();
byWebView.onResume();
}

@Override
protected void onDestroy() {
byWebView.onDestroy();
super.onDestroy();
}

Fan Hui Cao Zuo

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (byWebView.handleKeyEvent(keyCode, event)) {
return true;
} else {
return super.onKeyDown(keyCode, event);
}
}

Shang Chuan Tu Pian Zhi Hou De Hui Diao

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
byWebView.handleFileChooser(requestCode, resultCode, intent);
}

Jian Ting Biao Ti , Jin Du Tiao , WebViewClient

byWebView = ByWebView
.with(this)
.setWebParent(container, new LinearLayout.LayoutParams(-1, -1))
.useWebProgress(ContextCompat.getColor(this, R.color.coloRed))
.setOnTitleProgressCallback(onTitleProgressCallback)
.setOnByWebClientCallback(onByWebClientCallback)
.addJavascriptInterface("injectedObject", new MyJavascriptInterface(this))
.loadUrl(mUrl);
private OnTitleProgressCallback onTitleProgressCallback = new OnTitleProgressCallback() {
@Override
public void onReceivedTitle(String title) {
Log.e("---title", title);
}

@Override
public void onProgressChanged(int newProgress) {
// Fan Hui De Jin Du
}

@Override
public boolean onHandleScreenOrientation(boolean isShow) {
// Fan Hui true,Shi Pin Quan Ping Shi ,Heng Shu Ping Zi Ji Chu Li
return false;
}
};

private OnByWebClientCallback onByWebClientCallback = new OnByWebClientCallback() {

@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {

}

@Override
public boolean onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
// Ru Guo Zi Ji Chu Li ,Xu Yao Fan Hui true
return super.onReceivedSslError(view, handler, error);
}

@Override
public void onPageFinished(WebView view, String url) {
// Wang Ye Jia Zai Wan Cheng Hou De Hui Diao
}

@Override
public boolean isOpenThirdApp(String url) {
// Chu Li San Fang Lian Jie
Log.e("---url", url);
return ByWebTools.handleThirdApp(ByWebViewActivity.this, url);
}
};

Zi Ding Yi Cuo Wu Ye Mian

ByWebView.with(this)
.setErrorLayout(R.layout.by_load_url_error,"Wu Fa Da Kai Wang Ye ")
.loadUrl(mUrl);

Wan Zheng She Zhi

byWebView = ByWebView
.with(this)
.useWebProgress(true) // Shi Fou Shi Yong Jin Du Tiao ,Mo Ren true,Ru Shi Yong Ke Bu Yong Pei Zhi
.setWebParent(container, new LinearLayout.LayoutParams(-1, -1)) // She Zhi WebViewFu Rong Qi
.useWebProgress("#ffb6cf", "#ff0000", 3)// Jin Du Tiao Jian Bian Se (Kai Shi Yan Se ,Jie Shu Yan Se ,Gao Du )
.setOnTitleProgressCallback(onTitleProgressCallback)// title He progress Jian Ting
.setOnByWebClientCallback(onByWebClientCallback) // WebViewClientJian Ting
.setErrorLayout(R.layout.by_load_url_error, "Wu Fa Da Kai Wang Ye ") // She Zhi Cuo Wu Ye Mian Ji Biao Ti
.addJavascriptInterface("injectedObject", new MyJavascriptInterface(this)) // She Zhi JsJian Ting
.loadUrl(mUrl);

Tip

  • Hun Yao Shi Ying Jia Shang (Tong Guo JSXiang Wang Ye Chuan Zhi ,Ru Bu Jia You Shi Hou Hui Chuan Zhi Shi Bai ):

    -keepattributes *Annotation*
    -keepattributes *JavascriptInterface*
    -keepclassmembers class * {
    @android.webkit.JavascriptInterface <methods>;
    }

Thanks

Other

About

WebView Quan Fang Mian Shi Yong ,JSJiao Hu , Jin Du Tiao , Shang Chuan Tu Pian , Cuo Wu Ye Mian , Shi Pin Quan Ping Bo Fang , Huan Qi Yuan Sheng App, Huo Qu Wang Ye Yuan Dai Ma , Bei Zuo Wei Di San Fang Liu Lan Qi Da Kai , DeepLink, [Teng Xun x5Shi Yong Shi Li ]

Topics

Resources

Readme

License

Apache-2.0 license

Stars

Watchers

Forks

Contributors