How could i use google meet, zoom or any of these videocall apps from a webview?
I'm trying to create video call from a webview in my android app but it says "the browser is not compatible, download chrome, firefox or edge"
I was able to use google meet in the desktop mode in my phone but when i try to use it in the webview it does not let me.
I think the problem is that webview is not using chrome as a browser inside the app and i cant use custom tabs because i need the video inside my app not in an external page.
This is my code now, which is working fine, opening the url in desktop mode but when i try to start the video the error comes up:
class CameraFragment : Fragment() {
private lateinit var binding: FragmentCameraBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_camera, container, false)
}
@RequiresApi(Build.VERSION_CODES.O)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding = FragmentCameraBinding.bind(view)
if (ContextCompat.checkSelfPermission(
requireContext(),
Manifest.permission.RECORD_AUDIO
) != PackageManager.PERMISSION_GRANTED && ContextCompat.checkSelfPermission(
requireContext(),
Manifest.permission.CAMERA
) != PackageManager.PERMISSION_GRANTED){
val permissions = arrayOf(
android.Manifest.permission.RECORD_AUDIO,
android.Manifest.permission.CAMERA
)
ActivityCompat.requestPermissions(requireActivity(), permissions, 0)
}
webViewSetup()
}
@RequiresApi(Build.VERSION_CODES.O)
private fun webViewSetup() {
binding.webView.webChromeClient = object : WebChromeClientCustomPoster() {
override fun onPermissionRequest(request: PermissionRequest) {
request.grant(request.resources)
}
}
val newUA = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"
binding.webView.apply {
settings.javaScriptEnabled = true
settings.domStorageEnabled = true
settings.mediaPlaybackRequiresUserGesture = false
settings.userAgentString = newUA
loadUrl("https://www.vectera.com/login/")
}
}
override fun onResume() {
super.onResume()
requireActivity().requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
}
override fun onStop() {
super.onStop()
requireActivity().requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
}
open inner class WebChromeClientCustomPoster : WebChromeClient() {
override fun getDefaultVideoPoster(): Bitmap? {
return Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888)
}
}
inner class MyWebViewClient : WebViewClient() {
override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
view.loadUrl(url)
return false
}
}
}
The message:
from Google meet, zoom or vetera not working with android webview

No comments:
Post a Comment