Contents

Views 1305 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print

Javascript를 통해 Activity의 함수를 호출할 때,

예제는 finish();를 호출해서 현재 창을 닫는다.


Using the linked page as an example, you should be able to do something like this:

WebAppInterface class

public class WebAppInterface {
    Activity mActivity;

    /** Instantiate the interface and set the activity */
    WebAppInterface(Activity activity) {
        mActivity = activity;
    }

    /** Finish activity from the web page */
    @JavascriptInterface
    public void finishActivity() {
        mActivity.finish();
    }
}


Now, in your activity you add the JS interface like this:

WebViewActivity

WebView webView = (WebView) findViewById(R.id.webview);
webView.addJavascriptInterface(new WebAppInterface(this), "Android");


And in your webpage, you can finish the activity by clicking a button, like this:

HTML Contents

<input type="button" value="Finish the activity now" onClick="finishActivity()" />

<script type="text/javascript">
    function finishActivity() {
        Android.finishActivity();
    }
</script>

[출처] http://stackoverflow.com/questions/20639476/calling-activity-function-from-separate-class


?

List of Articles
No. Category Subject Author Date Views
141 Develop [c++] mfc 윈도우에서 ODBC 사용하여 MDB파일 읽기.. ㅋㅋ file hooni 2013.04.23 9141
140 Develop [c++] MFC 모든 헤더와 라이브러리 설명 | [교류]Programming hooni 2013.04.23 7458
139 Develop [c++] mfc 기반 멀티수납(wall)시스템 소스와 실행파일 file hooni 2013.04.23 7075
138 Develop [c++] mfc 기반 레지스트리(registry) 컨트롤 예제 코드 2 hooni 2013.04.23 15368
137 Develop [c++] mfc 간단한 파일 입출력 예제 hooni 2013.04.23 13551
136 Develop [c++] MD5 구현 소스.. 퍼움.. file hooni 2013.04.23 24138
135 Develop [c++] BHO 프로그램 동작 원리.. 간단하게.. hooni 2013.04.23 43145
134 Develop [C++] 18일차 과제물, String 클래스 디자인 【 C++ 문제 】 hooni 2013.04.23 7055
133 Develop [c#]업글 뉴 툴바 개인적으로 만든거.. (new) ㅋㅋ secret hooni 2013.04.23 7651
132 Develop [c#]뉴 툴바 개인적으로 만든거.. (old) secret hooni 2013.04.23 4272
131 Develop [c#]뉴 툴바 개인적으로 만든거.. (new) secret hooni 2013.04.23 7724
130 Develop [c#] 파일(File) 쓰기 ㅎㅎ hooni 2013.04.23 13317
Board Pagination Prev 1 ... 82 83 84 85 86 87 88 89 90 91 ... 98 Next
/ 98