Android Question Webview - How to handle "New Tab"

Discussion in 'Android Questions' started by tdocs2, Apr 10, 2015.

  1. tdocs2

    tdocs2 Well-Known Member Licensed User

    Greetings, all.

    Thank you in advance for answering my question.

    Code:
    WebViewGCalendar.LoadUrl("http://www.google.com/calendar")
    This instruction loads the Google Calendar in a webview. In the Google Calendar, click "More" (next to the Settings icon"), and it shows a dropdown menu with the choice to Print. Click Print and the Webview goes blank.

    Open the Google Calendar in Android Chrome. Click Print. A new Tab is opened with the Print Dialog.

    How can I do this in a Webview? No events seem to be triggered when I click Print inside the Webview.

    Any and all help is welcomed.

    Sandy
     
  2. DonManfred

    DonManfred Expert Licensed User

    Webview does not support "Tabs". It does not support new windows too.
    I believe you need to setup a javascript-interface and a chrome-client to the webview to get javascript-events and a javascriptconsole. The print-dialog is a new window (popup).
    Maybe you can catch the url in the java-script-events / javascriptconsole

    Sorry but i cannot provide an example as i dont have one. Just my 2cent
     
    tdocs2 likes this.
  3. tdocs2

    tdocs2 Well-Known Member Licensed User

    Thank you, Don.

    This is above my skillset.

    Best regards.

    Sandy
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Try to handle the OverrideUrl and look for the "print" url.
     
  5. tdocs2

    tdocs2 Well-Known Member Licensed User

    Thank you, Erel.

    The OverrideUrl event is not triggered when I select Print.

    The PageFinished is triggered whenever I click on the drop down "More" on the calendar, but when I select Print, I just get a blank screen and the OverrideUrl event is not triggered.

    Code:
    Sub WebViewGCalendar_OverrideUrl (Url As StringAs Boolean
    Log ("Url "&Url)

    Return False

    End Sub
    Sub WebViewGCalendar_PageFinished (Url As String)
    Log ("Page Fin Url "&Url)

    End Sub
    Sandy
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    This means that the url is not changing. They are probably using an ajax request instead.
     
  7. tdocs2

    tdocs2 Well-Known Member Licensed User

    Thank you, Erel.

    In Android Chrome, it opens a new tab and the URL shows as "about:blank" on a Print Request.

    Sorry, I do not know what an ajax request is.
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    Ajax request is an internal web request sent from the JavaScript code. There is no simple way to catch this request.
     
  9. tdocs2

    tdocs2 Well-Known Member Licensed User

    Thank you, Erel.
     
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