android
[Kotlin] Geckoview tutorial
liz_devel
2022. 12. 19. 11:01
build.gradle 설정
implementation "org.mozilla.geckoview:geckoview-$geckoviewChannel:$geckoviewVersion"
처음에 ext 설정을 연두색 칸 안에 있는 것처럼 설정해서 에러가 났다
밑에 있는 코드로 설정했더니 수정되었다
ext {
geckoviewChannel = "arm64-v8a"
geckoviewVersion = "83.0.20201112153044"
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<layout 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">
<data>
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<org.mozilla.geckoview.GeckoView
android:id="@+id/gecko_view"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
MainActivity.kt
class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
private val builder = GeckoRuntimeSettings.Builder()
.javaScriptEnabled(true)
.consoleOutput(true)
.remoteDebuggingEnabled(true)
private val geckoSession = GeckoSession()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
setupGeckoView()
}
private fun setupGeckoView() {
geckoSession.settings.displayMode = GeckoSessionSettings.DISPLAY_MODE_FULLSCREEN
val runtime = GeckoRuntime.create(this, builder.build())
geckoSession.open(runtime)
binding.geckoView.setSession(geckoSession)
geckoSession.loadUri("about:buildconfig")
}
}
GeckoView Android 튜토리얼 : 시작하기
GeckoView Android 튜토리얼 : 시작하기 IOS Development 386 Views WebView 를 사용하여 없이 웹 페이지 또는 일부 웹 콘텐츠 를로드 할 수 있다고 말하면 어떻게 될까요? 심지어 가능할까요? 예, GeckoView 와 같
appleglitz.com
https://www.kodeco.com/1381698-android-tutorial-for-geckoview-getting-started
반응형