web.html


<script>
        function callbackFunctionName() {
            $('input[name=keyword]').focus();
        }
       
        $(function() {
            location.href = 'iwtapplink-command://initFocusWithSoftKeyboard?callback=callbackFunctionName';

        });
    </script>



android app

    public boolean shouldOverrideUrlLoading(WebView paramWebView, String paramString) {
        if (paramString.startsWith(activity.getString(R.string.appLinkIwtCommandInitFocusWithSoftKeyboard))) {
                InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);

                String callback = "callbackFunctionName";
                if(paramString.indexOf("?") > 0) {
                    try {
                        Map<String, String> queryStringMap = StringUtil.queryStringToMap(paramString.replace(activity.getString(R.string.appLinkIwtCommandInitFocusWithSoftKeyboard) + "?", ""));

                        if (!TextUtils.isEmpty(queryStringMap.get("callback"))) {
                            callback = queryStringMap.get("callback");
                        }
                    } catch (UnsupportedEncodingException uee) {

                    }
                }

                webView.loadUrl("javascript:" + callback + "();");

                return true;
            }

            return false;
        }

Posted by incree

2018/06/06 03:50 2018/06/06 03:50
, ,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/395

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

안드로이드 웹뷰 액티비티를 사용하고 정상적으로 종료하지 않았을때

fabric log


Crash Insights
Heads Up!
Unable to add window -- token is not valid; is your activity running?

Details:
This crash is usually caused by your app trying to display a dialog using a previously-finished Activity as a context. For example, this can happen if an Activity triggers an AsyncTask that tries to display a dialog when it is finished, but the user navigates back from the Activity before the task is completed.

s crash is usually caused by your app trying to display a dialog using a previously-finished Activity as a context. For example, this can happen if an Activity triggers an AsyncTask that tries to display a dialog when it is finished, but the user navigates back from the Activity before the task is completed.
Resources:
1. Android – Displaying Dialogs From Background Threads
2. Error : BinderProxy@45d459c0 is not valid; is your activity running?

Fatal Exception: android.view.WindowManager$BadTokenException
Unable to add window -- token android.os.BinderProxy@d21dce2 is not valid; is your activity running?
 Raw Text
android.view.ViewRootImpl.setView (ViewRootImpl.java:890)
com.android.webview.chromium.Ap.handleJsAlert (WebViewContentsClientAdapter.java:355)
org.chromium.android_webview.AwContentsClientBridge$$Lambda$2.run (Unknown Source:3)
android.os.Handler.handleCallback (Handler.java:751)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1358)
Show all 44 Threads

이와 같은 에러가 나면서 앱이 크래쉬 되는 경우가 있다.

webview activity를 종료한 후 결제등의 화면에서 세션이 종료되는 것을 알리는 alert를 띄워줄때 발생하는 경우가 있다.

activity만 종료했기 때문이고, webview도 distory 해주면 이 에러는 해결된다.

백버튼이나 액티비티 종료 버튼을 눌러서 종료할때

다음과 같이 webview를 distory 한후 activity를 finish 한다.

@Override
public void onBackPressed() {
webView.destroy();
finish();
}


사용자 삽입 이미지



Posted by incree

2018/01/26 23:16 2018/01/26 23:16
,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/385

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

정확하게는 재생이 안되는 것이 아니라 재생은 되는데, 화면이 안보일때 해결 방법

webview의 layter type을 softwore로 설정했다면 이를 삭제한다

webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

와 같이 설정한 곳이 있으면 삭제 또는 LAYER_TYPE_HARDWARE  로 변경


LAYER_TYPE_SOFTWARE 는 Android version에 따라서 webview 성능 향상을 위해 사용하라는 의견들이 많다







Posted by incree

2017/02/10 05:49 2017/02/10 05:49
, , , ,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/377

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

안드로이드 웹뷰 회전시 상태 유지

android:configChanges="orientation|keyboardHidden|screenSize"

screenSize 는 Android 3.2(API level 13) or higher device


Posted by incree

2016/06/01 22:16 2016/06/01 22:16
,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/367

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

[Android] Cookie 버그 - WebView, HttpClient

Android에서 쿠키 공유할때(로그인 Activity -> WebView) 보통 아래와 같은 방법으로 처리한다

01    DefaultHttpClient client;
02     
03    //gets all cookies from the HttpClient's cookie jar
04    List<Cookie> cookies = client.getCookieStore().getCookies();
05     
06            if (! cookies.isEmpty()){
07     
08                CookieSyncManager.createInstance(YourContext.this);
09                CookieManager cookieManager = CookieManager.getInstance();
10     
11                            //sync all the cookies in the httpclient with the webview by generating cookie string
12                for (Cookie cookie : cookies){
13                    
14                    sessionInfo = cookie;
15        
16                        String cookieString = sessionInfo.getName() + "=" + sessionInfo.getValue() + "; domain=" + sessionInfo.getDomain();
17                        cookieManager.setCookie(YOUR_DOMAIN, cookieString);
18                        CookieSyncManager.getInstance().sync();
19                }
20            }
출처 : http://eshyu.wordpress.com/2010/06/27/syncing-cookies-between-an-httpclient-and-a-webview/


위 방식으로 예전에 개발할때는 잘 작동을 했는데,

이번 개발에서는 쿠키가 사라져 버리는 증상이 발생을 했다.

로그는 WebView를 호출한 이후에도 CookieManager에 쿠키가 남아 있었다

WebView에만 cookie가 전달이 안되는 증상이었다.

결론은 Android Cookie에 버그 때문.

Cookie 표준대로 작동안하니 버그라고 해도 될듯


Cookie 생성할때 모든 서브도메인까지 같이 적용되게 하려면

.domain.com 형식으로 도메인을 지정한다(맨 앞에 쩜 중요)


그런데 Android에서 이 형태의 도메인을 인식하지 못한다

2.1, 2.2, 2.3.3 까지 테스트 해 봤지만 모두 처리가 안됐다.

어쩔수 없이 고정 서브 도메인 하나만 지정하는 방법으로 처리했다.


일주일간 고생한걸 생각하면 ㅠㅠ.




p.s : 오늘 미국에 먼일 있나?? 오픈 소스 사이트들이 전부 이상한 안내 메시지 띄워 놓고
접속이 안되게 해놨네. 2011.01.18

Posted by incree

2012/01/18 20:30 2012/01/18 20:30
, , ,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/87

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

http://damianflannery.wordpress.com/2010/09/28/android-webview-with-https-loadurl-shows-blankempty-page/

I recently encountered this problem while trying to develop a WebView that is supported on Doughnut (1.6) and above. When presented with a https url the WebView just renders a blank page.

It seems that until Froyo, Android didn’t provide a public API to let you manually decide if you wanted to proceed to an untrusted web site via a WebView.

Note that in this case it is not even that the web site was untrusted (in the conventional sense) – it is because Thawte is not in the default list of trusted certificate authorities on Android. If you use the standard web browser on Android, the browser presents a typical warning dialog (as presented below) that enables you to accept the certificate and carry on.

Invalid certificate warning

If you are using Froyo as the target SDK then you can use:

1engine = (WebView) findViewById(R.id.my_webview);
2engine.setWebViewClient(new WebViewClient() {
3 public void onReceivedSslError (WebView view, SslErrorHandler handler, SslError error) {
4 handler.proceed() ;
5 }
6}

However, if you are not using Froyo then it seems you are out of luck. After some research, I concluded that I had the following options:

a) intercept all page requests and forward to external web browser if url begins with https (not a clean or nice user experience and totally unnecessary for Froyo and above)
b) add certificate of website to local keystore (in this case I am serving multiple web pages and the origin of many of these is not known until runtime)
c) make Froyo the minSDK and discard previous versions of Android (not a suitable option)
d) hack and use some private apis (the option described below)

To solve this problem we have to use a private interface (not published on SDK but present in real SDK runtime). As you can see in the Android src tree, the onReceivedSslError is indeed present (and used – it simply cancels the request) in Doughnut. However, this method is not presented to us in the SDK  - it is hidden because it contains a parameter type SslError which is located in a hidden package.  Therefore, we need to copy these src files into our project so that we can access them:

1) Copy WebViewClient.java into the package “android.webkit” within your src folder.
2) Copy SslError.java into the package “android.net.http” within your src folder.

Src files

3) Since we replicated the paths to the src files in the SDK, our code to override onSslError above now works on Android 1.6.

Caution: bear in mind that we are using a private API and Google reserve the right to change private APIs at any time – though in this case it is unlikely since they’ve now made this available in Froyo.

Posted by incree

2011/12/29 10:27 2011/12/29 10:27
, , ,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/85

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다


Notices

Archives

Authors

  1. incree

Recent Trackbacks

Calendar

«   2018/07   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        

Site Stats

Total hits:
472277
Today:
49
Yesterday:
232