기본 콘텐츠로 건너뛰기

글

라벨이 webview인 게시물 표시

cordova webview posturl

cordova webview posturl import android.webkit.WebView; import org.apache.cordova.*; import org.apache.http.util.EncodingUtils; public class MainActivity extends CordovaActivity { private static Dialog loginDialog; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String TRAGET_URL = "http://example.com/login/login_verify"; String POST_DATA = "login_id=test&login_pass=1111"; postUrl(TRAGET_URL,POST_DATA); } /** * Load the url into the webview. */ public void postUrl(String url,String data) { if (appView == null) { init(); } // If keepRunning this.keepRunning = preferences.getBoolean("KeepRunning", true); //appView.lo WebView mWebView = (WebView) appView.getView(); // WebView mWebView = (WebView) findViewById(R.id.mWebView); // WHERE R.id.mWebView is o...

android webview 새창 외부 브라우져 연결

wv . getSettings (). setSupportMultipleWindows ( true ); wv . setWebChromeClient ( new WebChromeClient () { @Override public boolean onCreateWindow ( WebView view , boolean dialog , boolean userGesture , android . os . Message resultMsg ) { WebView . HitTestResult result = view . getHitTestResult (); String data = result . getExtra (); Context context = view . getContext (); Intent browserIntent = new Intent ( Intent . ACTION_VIEW , Uri . parse ( data )); context . startActivity ( browserIntent ); return false ; } }); * 이미지 링크일경우 따로 처리 HitTestResult result = view .getHitTestResult();         if ( result .getType() == HitTestResult. SRC_IMAGE_ANCHOR_TYPE ) {         Message hrefMsg = new Message();             view .requestFocusNodeHref( hrefMsg );             String url ...

android webview post data

호출 순서 1. javascript 에서 post 할 데이터를 plugin 으로 보낸다. { "username":"홍길동" , "userpassword":"" } 2. 이 데이터를 안드로이드 플러그인에서 string 으로 만든 후 , Json Object 로 보낸다. String postData = "username="+  URLEncoder . encode ( username, "UTF-8" ); String params =  Base64.encodeToString(params.getBytes(), Base64.URL_SAFE); 3.WebView 호출하는데서는 2번에서 암호화 한 값을 풀어서, byte[] 로 보낸다. String tmp = new String(Base64.decode( params , Base64. URL_SAFE )); String url = "http://www.example.com" ; String postData = "username=my_username&password=my_password" ; webview . postUrl ( url , EncodingUtils . getBytes ( postData , "BASE64" )); 위와 같이 보낸다.

allow ajax header in Android webview and ios uiwebview

my application is hybrid app. both android and ios works. local contents is loaded in apps. and add additional headers ajax server call. In my work around , server modification not allowed. local-content ajax add header. (ref http://stackoverflow.com/questions/3258645/pass-request-headers-in-a-jquery-ajax-get-call ) $ . ajax ({ url : "/test" , headers : { "X-Test-Header" : "test-value" } }); Android webview setting ( ref : http://stackoverflow.com/questions/8648616/webview-javascript-cross-domain-from-a-local-html-file ) Initialize your WebView: WebView _webView = ( WebView ) this . findViewById ( R . id . id_of_your_webview_in_layout ); get WebView settings: WebSettings settings = _webView . getSettings (); set following settings: settings . setJavaScriptEnabled ( true ); settings . setAllowFileAccessFromFileURLs ( true ); //Maybe you don't need this rule settings . setAllowUniversalAccessFromFileUR...