Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

395
Views
Android, webview, inyecta código Java/Kotlin en Javascript

Tengo código Javascript (eliminé la mayor parte del código)

 var url = // some url; __webpack_exports__["default"] = ({ filters: { // some code }, components: { // some components }, data: function data() { return { // some data, phone: '', // somde data }; }, created: function created() { var _this2 = this; window.actions = {}; window.actions.getPhoneNumber = function (number) { _this2.phone = number; }; window.Android && (window.Android.getPhoneNumber = function (number) { _this2.phone = number; }); },

Y código en Android en fragmento onCreated

 @SuppressLint("SetJavaScriptEnabled") private fun configureViews() { webview.webViewClient = TransfersWebViewClient(injectJs = { injectJavaScript() }) webview.settings?.javaScriptEnabled = true webview.loadUrl(startUrl) }

Realice el cliente webview

 class TransfersWebViewClient( private val injectJs: (() -> Unit)? = null, ) : WebViewClient() { override fun onPageFinished(view: WebView?, url: String?) { super.onPageFinished(view, url) injectJs?.invoke() } }

Y la implementación de la función injectJavaScript()

 private fun injectJavaScript() { webview.evaluateJavascript("actions.getPhoneNumber('33333');", null) }

necesito pasar a la función javascript window.actions.getPhoneNumber = función (número) { _this2.phone = número; }; mi número de teléfono, pero no puedo hacerlo. ¿Por favor dime cómo hacer esto?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!