diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 83095da4..70b02851 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -20,19 +20,20 @@ android:usesCleartextTraffic="true"> - - - - - + android:exported="false"> + android:exported="true"> + + + + + + diff --git a/app/src/main/assets/webviewexam.html b/app/src/main/assets/webviewexam.html new file mode 100644 index 00000000..9633f186 --- /dev/null +++ b/app/src/main/assets/webviewexam.html @@ -0,0 +1,20 @@ + + + + + + + +

+ 로딩이 완료된 웹뷰 입니다. +

+ + + + + \ No newline at end of file diff --git a/app/src/main/java/com/dogdduddy/jmt/view/WebAppInterface.kt b/app/src/main/java/com/dogdduddy/jmt/view/WebAppInterface.kt new file mode 100644 index 00000000..028294f5 --- /dev/null +++ b/app/src/main/java/com/dogdduddy/jmt/view/WebAppInterface.kt @@ -0,0 +1,15 @@ +package com.dogdduddy.jmt.view + +import android.content.Context +import android.webkit.JavascriptInterface +import android.widget.Toast + +/** Instantiate the interface and set the context */ +class WebAppInterface(private val mContext: Context) { + + /** Show a toast from the web page */ + @JavascriptInterface + fun showToast(toast: String) { + Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/dogdduddy/jmt/view/WebViewActivity.kt b/app/src/main/java/com/dogdduddy/jmt/view/WebViewActivity.kt index d955dcb4..6e0f416f 100644 --- a/app/src/main/java/com/dogdduddy/jmt/view/WebViewActivity.kt +++ b/app/src/main/java/com/dogdduddy/jmt/view/WebViewActivity.kt @@ -20,10 +20,14 @@ class WebViewActivity : AppCompatActivity() { webView = binding.webView webViewInit() - + /* intent.extras?.let { binding.webView.loadUrl(it.getString("url")!!) } + // https://jmt-matzip.dev/ + */ + //binding.webView.loadUrl("file:///android_asset/webviewexam.html") + binding.webView.loadUrl("https://jmt-matzip.dev/") val actionBar: ActionBar? = supportActionBar actionBar!!.hide() @@ -35,5 +39,6 @@ class WebViewActivity : AppCompatActivity() { window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) //화면이 계속 켜짐 requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_FULL_USER webView.setWebViewClient(WebViewClient()) + webView.addJavascriptInterface(WebAppInterface(this), "Android") } } \ No newline at end of file