Android Question cant use addChromeWebClient with WebViewExtras2

Juan Luis Lopez

Member
Licensed User
Longtime User
I have an app that uses a webview to navigate my website. that website, has a file input (that doesnt work with normal webviews) so i have been reading and found webviewextras2. Apparently i can open the file upload dialog using this library while using the addChromeWebClient method.
But after creating a webviewextras object, the autocomplete feature from the editor dont suggests me that method and underlines it in red. I cant compile the apk as well, method not found.

Any ideas??
 

Juan Luis Lopez

Member
Licensed User
Longtime User
Ok I soved that problem... Almost.

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Private Wbe As WebViewExtras
    Private Navegador As WebView
    Private ChromeClient As DefaultWebChromeClient
    Private Logo As ImageView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Cargamos el Layout
    Activity.LoadLayout("Main")
 
    'Inicializamos cosas
    Wbe.Initialize(Navegador)
    ChromeClient.Initialize("ChromeCLient")
 
    'Hacemos cosas
    Wbe.SetWebChromeClient(ChromeClient)
    Navegador.LoadUrl("http://mydomain.com")
 
End Sub

Sub Activity_KeyPress(KeyCode As Int) As Boolean
    'Actuamos con el boton atras en funcion de en qué página estemos
    Select KeyCode
        Case KeyCodes.KEYCODE_BACK
            If Navegador.Url = "http://mydomain.com/home" Or Navegador.Url = "http://mydomain.com/" Then
                ExitApplication
            End If
           
            If Wbe.CanGoback Then
                Navegador.Back
                Return True
            Else
                Navegador.LoadUrl("http://mydomain.com")
                Return True
            End If
    End Select

With this code, the file upload button opens a dialog (Not the same dialog as when you are using google chrome) but there is another problem... When i choose a file to upload, my webview navigates back!!! so i cant upload my file. I think that this is caused because, when you choose a file, the system "presses" the back button to go to the previous activity and my code detects this "press" and navigates back.


Any ideas how to avoid it?
 
Upvote 0
Top