반응형
| android, JavaScript Bridge |
JavaScript Bridge
하이브리드 앱을 만들 때 사용되는 방식으로,
HTML 에서 어떤 function call 을 하면 android webview 에서 catch 가능하다.
WebView.setJavaScriptEnabled( true );
WebView.addJavascriptInterface( new MyBridge(), "AppInterface" );
private class MyBridge{
public void functionName( String arg ){
// do sth..
}
}
<html>
function callAndroidFunction(){
window.AppInterface.functionName();
}
반대로 App 에서 JavaScript 의 function call 도 가능하다.
WebView.loadUrl("javascript:functionName");
<html>
fuction functionName(){
}
반응형
'프로그래밍 놀이터 > 안드로이드, Java' 카테고리의 다른 글
| [android] 삼성 핸드폰 계열의 버그. ( EditText & SoftInput 관련 ) (0) | 2014.03.18 |
|---|---|
| [Android] 제대로 된 REST API 를 구축해보자. (0) | 2014.03.18 |
| [android] DB 를 update 혹은 insert 할 떄 주의해야 할 것 ( thread ) (0) | 2014.03.13 |
| [android] manual application sign & zipaligning (0) | 2014.03.12 |
| [android] activity progressbar ( shown on actionbar if it exists ) (0) | 2014.03.11 |
댓글