Android Question webview popup

hitesh.k

Member
hello there i need to show a web page in web view, which i have managed successfully
the problem is with popup which is not showing.
i am trying with webviewextra 2
B4X:
class globals
dim webextra as webviewextra
dim webset as websettings

b4xmainpage
webextra.setwebchromeclient(webview1)
webset.getjavascriptcanopenwindowautomaticaly=true
webview1.loadurl("..........")
but getting errors in compile
 

hitesh.k

Member
Removed this line
B4X:
webextra.setwebchromeclient(webview1)

now compile err gone but err in logs


B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private WebView1 As WebView
   
    Dim webextra As WebViewExtras
    Dim webViewst As WebSettings
   

End Sub

Public Sub Initialize
'    B4XPages.GetManager.LogEvents = True
End Sub

'This event will be called once, before the page becomes ccvisible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    ProgressDialogShow("Loading plz wait......")

   
  webViewst.SetJavaScriptCanOpenWindowsAutomatically(True)
    If webViewst.GetJavaScriptCanOpenWindowsAutomatically Then
32:    WebView1.LoadUrl("")
    Else
        ToastMessageShow("not enabled",True)
    End If
End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.



Private Sub WebView1_PageFinished (Url As String)
    ProgressDialogHide
End Sub
error:
--------- beginning of main
Copying updated assets files (18)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Error occurred on line: 32 (B4XMainPage)
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1087)
    at b4a.example.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:1070)
    at b4a.example.b4xpagesmanager._showpage(b4xpagesmanager.java:427)
    at b4a.example.b4xpagesmanager._addpage(b4xpagesmanager.java:247)
    at b4a.example.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:261)
    at b4a.example.b4xpagesmanager._initialize(b4xpagesmanager.java:167)
    at b4a.example.main._activity_create(main.java:418)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at b4a.example.main.afterFirstLayout(main.java:105)
    at b4a.example.main.access$000(main.java:17)
 
Upvote 0

hitesh.k

Member
full error log i think first few lines are important:
Logger connected to:  samsung SM-A515F
--------- beginning of main
Copying updated assets files (18)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Error occurred on line: 31 (B4XMainPage)
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1087)
    at b4a.example.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:1070)
    at b4a.example.b4xpagesmanager._showpage(b4xpagesmanager.java:427)
    at b4a.example.b4xpagesmanager._addpage(b4xpagesmanager.java:247)
    at b4a.example.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:261)
    at b4a.example.b4xpagesmanager._initialize(b4xpagesmanager.java:167)
    at b4a.example.main._activity_create(main.java:418)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at b4a.example.main.afterFirstLayout(main.java:105)
    at b4a.example.main.access$000(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:83)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8741)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:336)
    at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:285)
    ... 25 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
    ... 26 more
Caused by: java.lang.RuntimeException: Object should first be initialized (WebViewExtras).
Did you forget to call Activity.LoadLayout?
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
    at uk.co.martinpearman.b4a.webkit.WebViewExtras.AddJavascriptInterface(WebViewExtras.java:21)
    at b4a.example.b4xmainpage._b4xpage_created(b4xmainpage.java:65)
    ... 28 more
** Activity (main) Resume **
 
Upvote 0

hitesh.k

Member
ok partial problem solved by using advwebview lib now popups is visible one of the popup is a WhatsApp icon which open WhatsApp
when pressed which is working in browsers but in advwebview open a err msg url scheme not found any idea ?
 
Upvote 0

hitesh.k

Member
B4X:
Private Sub AdvancedWebView1_onPageError(errorCode As Int, description As String, failingUrl As String)
    
    If failingUrl.Contains("whatsapp")Then
        Dim Intent1 As Intent
        
        Intent1.Initialize(Intent1.ACTION_VIEW, failingUrl)
        StartActivity(Intent1)

    End If
    
        
    
    End Sub
made this for open whatsapp
 
Upvote 0
Top