B4J Question B4J Enable WebView to Download a file example

Discussion in 'B4J Questions' started by Fabio Fabozzi, Mar 9, 2015.

  1. Fabio Fabozzi

    Fabio Fabozzi Member Licensed User

    Hi,

    I would like to see how and if is possible to download a file from a webview.

    Thanks
     
  2. billzhan

    billzhan Active Member Licensed User

    Do you mean the webview embedded in a java(ui) progromme or a non-ui b4j server?
     
  3. Fabio Fabozzi

    Fabio Fabozzi Member Licensed User

    I try to explain. In a web app, I have a button "download". So this button has a server side script that sends out to browser the file. Normally, if you push this button with the default browser, the action is the physical download of a file. I thought, if webview is based on default android's webbrowser, I think is possible to obtain the same effect. Could it be?
     
  4. billzhan

    billzhan Active Member Licensed User

    I guess you are trying to use android webview to download a file from a url, this should be a b4a question.

    See http://www.b4x.com/android/forum/threads/webview-cant-download-file.38708/#content


    Code:
    Sub WebView1_OverrideUrl (Url As StringAs Boolean
        
    If Url.EndsWith(".pdf")
            downloadfile(Url)  
    'function to download file
            Return True  'Don't try to navigate to this URL
           
        
    End If 
       
    Return False
    End Sub
     
  5. Fabio Fabozzi

    Fabio Fabozzi Member Licensed User

    First of all thank you. I just tried this way, both on B4A and B4J, but unfortunately doesn't match my case
     
  6. billzhan

    billzhan Active Member Licensed User

    It should work. You can upload a demo and see what we can do
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice