I'm making a WebView within an application to respond to a JotForm form, this form has a button to send files, how do I make it so that when the button is clicked, the application opens the device's file explorer? this is my Kotlin Code
package com.example.orgs
import android.annotation.SuppressLint
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.KeyEvent
import android.view.Window
import android.webkit.WebChromeClient
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.appcompat.app.AppCompatActivity
class SecondActivity : AppCompatActivity() {
private lateinit var view: WebView
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
if ((keyCode == KeyEvent.KEYCODE_BACK) && view.canGoBack()) {
view.goBack()
return true
}
return super.onKeyDown(keyCode, event)
}
@SuppressLint("SetJavaScriptEnabled")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
supportRequestWindowFeature(Window.FEATURE_NO_TITLE)
setContentView(R.layout.activity_second)
view = findViewById(R.id.webView)
view.settings.javaScriptEnabled = true
view.settings.builtInZoomControls = false
view.webViewClient = MyWebClient()
view.loadUrl("https://form.jotform.com/230447298445059")
view.webChromeClient = WebChromeClient()
}
private inner class MyWebClient : WebViewClient() {
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
if (url?.startsWith("tel:") == true || url?.startsWith("whatsapp:") == true) {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
startActivity(intent)
return true
}
return false
}
}
}