링크주소에 안드로이드 스튜디오에서 다운받아서 설치 후 아래 소스를 추가하면 끝...
AI로 하니 금방 만들수 있네요..
MainActivity.kt
[code]
package com.seoul.seoulforeign
import android.annotation.SuppressLint
import android.os.Bundle
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.viewinterop.AndroidView
import com.seoul.seoulforeign.ui.theme.SeoulForeignTheme
class MainActivity : ComponentActivity() {
// WebView를 참조할 변수 선언
private lateinit var webView: WebView
@SuppressLint("SetJavaScriptEnabled")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
SeoulForeignTheme {
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
WebViewer(
url = "https://sir.kr",
modifier = Modifier.padding(innerPadding),
onWebViewCreated = { webView = it }
)
}
}
}
}
// 뒤로가기 버튼 처리
override fun onBackPressed() {
if (::webView.isInitialized && webView.canGoBack()) {
webView.goBack()
} else {
finish() // 앱 종료
}
}
}
@Composable
fun WebViewer(
url: String,
modifier: Modifier = Modifier,
onWebViewCreated: (WebView) -> Unit
) {
AndroidView(
modifier = modifier.fillMaxSize(),
factory = { context ->
WebView(context).apply {
webViewClient = WebViewClient()
settings.javaScriptEnabled = true
loadUrl(url)
onWebViewCreated(this)
}
}
)
}
[/code]
AndroidManifest.xml
[code]
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<!-- ? 인터넷 권한 추가 -->
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.SeoulForeign">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.SeoulForeign">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
[/code]
구글 스토어에 업로드 할려면 비용이 들지만...
댓글 2개
게시글 목록
| 번호 | 제목 |
|---|---|
| 2136 |
Android
안드로이드 웹뷰어
2
현재글
|
| 2131 | |
| 2122 | |
| 2112 |
Hybrid
최근 svelte로 만든 하이브리드앱들
5
|
| 2108 | |
| 2106 | |
| 2102 | |
| 2099 |
Hybrid
캐패시터 (Ionic Capacitor)
|
| 2093 |
Hybrid
vue native 어떤가여 ㅋㅋ
7
|
| 2084 |
Hybrid
플러터와 네이티브 어플
3
|
| 2080 | |
| 2077 | |
| 2070 | |
| 2068 |
IOS
넷플릭스앱
|
| 2067 |
기타
C++
|
| 2065 | |
| 2064 | |
| 2063 | |
| 2062 | |
| 2059 | |
| 2055 |
Android
안드로이드 앱 퍼블리셔 / 운영팀 or 사업부
|
| 2053 | |
| 2047 | |
| 2044 | |
| 2037 | |
| 2036 | |
| 2033 | |
| 2027 | |
| 2026 | |
| 2025 |
기타
Flutter 2
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기