topWebview
webviewExample
composeWebview
androidWebview.subtitle
- androidWebview.description1
- androidWebview.description2
kotlin
// build.gradle (:app)
android {
// ...
buildFeatures {
viewBinding true
}
// ...
}
androidWebview.step1title
androidWebview.step1description1
- androidWebview.step1description1-1
xml
<!-- res/layout/activity_launcher.xml -->
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
tools:context=".LauncherActivity">
<WebView
android:id="@+id/webViewLauncher"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
androidWebview.step1description2
<application></application>
androidWebview.step1description2-1- androidWebview.step1description2list1
- androidWebview.step1description2list2
- androidWebview.step1description2list3
xml
<!-- AndroidManifest.xml -->
<application ...>
...
<activity
android:name=".LauncherActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.{projectName}.NoActionBar"
tools:ignore="LockedOrientationActivity" />
...
</application>
androidWebview.step2title
androidWebview.step2subtitle
androidWebview.step2description1title
androidWebview.step2description1subtitle
androidWebview.step2description1jscode
- androidWebview.step2description1jscodeList
kotlin
binding.webViewLauncher.apply {
// ...
// JavascriptInterface 추가
addJavascriptInterface(
ExampleWebAppInterface(this@LauncherActivity),
"BlpLauncher"
)
// ...
}
androidWebview.step2description1class
- androidWebview.step2description1classlist1
Interface function | Description |
---|---|
closeLauncher() | androidWebview.item2 |
kotlin
// 블리피 Launcher Web <-> App 인터페이스 규격
class ExampleWebAppInterface(private val mContext: Context) {
fun closeLauncher() {
// 런처 뒤로가기 > 런처 종료
(mContext as Activity).finish()
}
}
androidWebview.step2description2title
androidWebview.step2description2subtitle
- androidWebview.step2description2list1
- androidWebview.step2description2list2
kotlin
binding.webViewLauncher.settings.apply {
javaScriptEnabled = true // 자바 스크립트 허용
domStorageEnabled = true // storage enabled (로컬 스토리지 사용하여 dom 가져올 수 있도록 함)
}
androidWebview.step2description3title
androidWebview.step2description3subtitle
kotlin
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// ...
binding.webViewLauncher.apply {
// WebView에 블리피 런처 URL을 로드
loadUrl("런처 URL")
}
// ...
}
androidWebview.step3title
androidWebview.step3subtitle
kotlin
// WebView 초기화 및 destroy - 메모리 누수 방지
override fun onDestroy() {
super.onDestroy()
binding.webViewLauncher.apply {
clearHistory()
loadUrl("about:blank")
removeAllViews()
destroy()
}
}
footerTitle
"[Client Admin] footerMessage
v1.0.6