Spanish (SOLUCIONADO) Falla WebView

J M Movilla Cuadrado

Member
Licensed User
De nuevo dando guerra... Llevo varias horas buscando y rebuscando sin encontrar solucionar este problema.

B4X:
Sub Process_Globals
End Sub

Sub Globals
End Sub

Sub Activity_Create(FirstTime As Boolean)
    MyOfficeWeb
End Sub

Sub MyOfficeWeb
    Dim myw As WebView
    myw.Initialize("myw")
    Activity.AddView(myw, 0, 0, 100%x, 100%y) 'Your options for size here
'    myw.LoadUrl(VerDatos.cWEB)
    myw.LoadUrl("http://www.google.com") ' Ni aun así funciona...
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Con este código, que informan como válido para abrir una web, a mí me da error de
"Página web no disponible. No ha sido posible cargar la página web http://www.google.com/ porque net::ERR_CONNECTION_REFUSED"

Y aquí me tenéis, esperando vuestra ayuda, que sin dudarlo será tan efectiva como en consultas anteriores. Mil gracias desde ya...
 

rscheel

Well-Known Member
Licensed User
Longtime User
Prueba esto

B4X:
Sub Process_Globals
End Sub

Sub Globals
    Dim myw As WebView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    myw.Initialize("myw")
    Activity.AddView(myw, 0, 0, 100%x, 100%y) 'Your options for size here
    myw.LoadUrl("http://www.google.com") ' Ni aun así funciona...
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Si no funciona así, crea un layout y carga el objeto al layout en el diseñador.
 

J M Movilla Cuadrado

Member
Licensed User
Te agradezco mucho tu interés, pero tu código me da el mismo error.

Ya tengo todo en un layout, por eso tengo la línea "myw.LoadUrl(VerDatos.cWEB)". Y creo haber probado más o menos esa opción que me propones... La verdad es que me resulta super raro este dichoso fallo. Gracias.
 

rscheel

Well-Known Member
Licensed User
Longtime User
Prueba este código

Manifest

B4X:
AddPermission("android.permission.INTERNET")

B4X:
Sub Process_Globals
    Dim Obj1 As Reflector
End Sub

Sub Globals
    Dim UrlRendimiento As String = "https://www.google.cl"
    Private WViewRend As WebView
    Dim WebViewExt As WebViewExtras
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("WebViewRendimiento")
    Activity.Title = "RENDIMIENTO"
    WebViewExt.Initialize(WViewRend)
    WebViewExt.GetSettings.SetDisplayZoomControls(False)
    WebViewExt.ZoomEnabled = True
    WebViewExt.ClearCache(True)
    WViewRend.LoadUrl(UrlRendimiento)
    Obj1.Target = WebViewExt
    Obj1.RunMethod2("setInitialScale", "100", "java.lang.int")
End Sub

Necesitas las librerias WebViewExtras y Reflection
 

J M Movilla Cuadrado

Member
Licensed User
Intentaré buscar y bajar la librería WebViewExtras, y te contaré. Gracias.
 
Last edited:

J M Movilla Cuadrado

Member
Licensed User
Ahora me encuentro con la MURALLA... ¿Cómo confecciono el WebViewRendimiento?

Ten en cuenta que soy más novato que un niño de teta... a pesar de (o precisamente por) ¡mis 87 años!

En la línea "Dim WebViewExt As WebViewExtras" me dice que Este es un 'Objeto de actividad', no se puede declarar en Sub Process_Globals.

Y con el diseñador no encuentro cómo añadir ninguna vista relacionada con WebViewExtras.
 
Last edited:

J M Movilla Cuadrado

Member
Licensed User
Estoy probando este otro código, que no me da error, pero no me presenta la página; se me queda todo vacío... salvo el título.
B4X:
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim WebView1 As WebView
End Sub

Sub Activity_Create(FirstTime As Boolean)

    WebView1.Initialize("WebView1")
    WebView1.JavaScriptEnabled = True
    WebView1.ZoomEnabled = True
    WebView1.Color = Colors.Blue
  
    Dim Obj1 As Reflector
    Obj1.Target = WebView1
    Obj1.RunMethod2("setInitialScale", "50", "java.lang.int") ' el 100 seria sin zoom
  
    Activity.Title=VerDatos.cWEB

    Try
'        WebView1.LoadUrl(VerDatos.cWEB)
        WebView1.LoadUrl("http://www.google.com")
    Catch
        Msgbox(LastException,"Error")
    End Try
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 

J M Movilla Cuadrado

Member
Licensed User
¡Jesús San Señor!!! La de vueltas que le he dado al tema, y me he encontrado lo más maravilloso, en un post de Erel, en que da la solución con algo tan escueto y efectivo como esto:
B4X:
Dim p As PhoneIntents
StartActivity(p.OpenBrowser(cWEB))
donde "cWEB" es el link que he leído de mi db...
 
Top