Android Question javascript in webview?

fifiddu70

Well-Known Member
Licensed User
Longtime User
hi, i have a ipcam f series connected in internet, i need to make a little app for view this ip cam, i make a designer with webview but the javascript is not visible, i see only ?
i insert the javascript.enabled = true but not work.
 

Attachments

  • op.png
    op.png
    64.3 KB · Views: 246

fifiddu70

Well-Known Member
Licensed User
Longtime User
i have this code, but not work with WebviewExtras.

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim MyWebViewExtras As WebViewExtras
    Dim WebView1 As WebView
    Dim p As Phone
    Dim adview1 As AdView
    Dim lblcisar As Label
    Dim pw As PhoneWakeState
    Dim lblwebcam As Label
    Dim lblwaith As Label
    Dim answ As Int
       
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("partanna")
    p.SetScreenOrientation(1)
   
    adview1.Initialize("AdView1","a1510d125a9b52e")
    Activity.AddView(adview1, (Activity.Width - 320dip) / 2, Activity.Height - 50dip, 320dip, 50dip)
    adview1.LoadAd
    adview1.Visible=False
    WebView1.SetLayout(0%x,5%y,155%x,55%y)
    lblwaith.SetLayout(0%x,0%y,100%x,55%y)
    lblcisar.SetLayout(0%x,50%y,100%x,7%y)
    lblwebcam.SetLayout(0%x,72%y,100%x,7%y)
    'webview1.LoadUrl("http://partannawebcam.dlinkddns.com/snapshot.cgi?user=visitatore1&pwd=partanna")
    'WebView1.LoadUrl("http://partannawebcam.dlinkddns.com/monitor.htm?user=visitatore1&pwd=partanna")
    WebView1.Height=100%y/2
    WebView1.Width=100%x
    WebView1.LoadUrl("http://partannawebcam.dlinkddns.com/monitor.htm?user=visitatore1&pwd=partanna")
    MyWebViewExtras.addJavascriptInterface(WebView1, "B4A")
End Sub
Sub webview1_PageFinished (Url As String)
    'webview1.SetLayout(-51%x,-5%y,155%x,55%y)
    lblwaith.Visible=False
End Sub
Sub Activity_Resume
    pw.KeepAlive(True)
End Sub
Sub Activity_KeyPress (KeyCode As Int)  As Boolean
    If KeyCode = KeyCodes.KEYCODE_BACK Then   
    answ = Msgbox2("Sei sicuro di voler uscire dal programma?","ATTENZIONE !!","SI","","NO",Null)
    If answ = DialogResponse.POSITIVE Then
    ExitApplication
    Return False
    Else
    End If
    End If
    Return True
End Sub
Sub Activity_Pause (UserClosed As Boolean)
    pw.ReleaseKeepAlive
End Sub
Sub lblcisar_Click
    Dim i As Intent
    i.Initialize(i.ACTION_VIEW, "http://www.siciliabit.com")
    StartActivity (i)
End Sub

wher is the error?
 
Upvote 0

fifiddu70

Well-Known Member
Licensed User
Longtime User
Hi Erel, it seems that using an active x to view the video from the internet explorer, but it is also possible to see through a smartphone-enabled javascript, if I open the internet browser of the phone I see the video of ipcam, but if I open with webview, I can not view the video, instead of video displays an icon with the symbol?, because with webview not seen and with the external browser you see? it is possible to open the browser in a panel in order to display it in my application?
my need is to display the video in my application and not from the phone's browser.
this is the address of ipcam: http://partannawebcam.dlinkddns.com/pda.htm from phone, user is: visitatore1 and password: partanna.
 
Upvote 0

fifiddu70

Well-Known Member
Licensed User
Longtime User
i have a momentanely problem with the ddns server, the ipcam is not available now, i search a very good free ddns for my ipcam.
 
Upvote 0

fifiddu70

Well-Known Member
Licensed User
Longtime User
ok now this ipcam is available on the internet.
how do I display the webview the video of ipcam? does anyone know help me?
 
Upvote 0

fifiddu70

Well-Known Member
Licensed User
Longtime User
I solved this way

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim timer1 As Timer
    Dim timer2 As Timer
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 mycam As Videomjpeg
    Dim c  As Canvas
    Dim p As Panel
    Dim DestRect As Rect
    Dim pw As PhoneWakeState
    Dim lblwaith As Label
    Dim answ As Int
    Dim imgsplash As ImageView
    Dim WebView1 As WebView
End Sub
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("partanna")
    If FirstTime =True Then
    timer1.Initialize("timer1",250)
    timer2.Initialize("timer2",7000)
    timer2.Enabled = True
    timer1.Enabled=True
    End If
    p.SetLayout(0%x,0%y,100%x,55%y)
    imgsplash.SetLayout(0%x,0%y,100%x,100%y)
    lblwaith.SetLayout(0%x,0%y,100%x,55%y)
   
End Sub
Sub Activity_Resume
    pw.KeepAlive(True)
End Sub
Sub timer1_tick
    maj_cam
End Sub
Sub timer2_tick
    imgsplash.Visible=False
    timer2.Enabled=False
End Sub
Sub maj_cam
    mycam.cam("partannawebcam.dlinkddns.com",80,"/videostream.cgi?user=visitatore1&pwd=partanna")
    c.Initialize(p)
    DestRect.Initialize(0,0,p.Width,p.Height)
    c.DrawDrawable(mycam.Image,DestRect)
    mycam.unbindDrawables(p)
    Activity.Invalidate
End Sub

Sub Activity_KeyPress (KeyCode As Int)  As Boolean
    If KeyCode = KeyCodes.KEYCODE_BACK Then   
    answ = Msgbox2("Sei sicuro di voler uscire dal programma?","ATTENZIONE !!","SI","","NO",Null)
    If answ = DialogResponse.POSITIVE Then
    ExitApplication
    Return False
    Else
    End If
    End If
    Return True
End Sub
Sub Activity_Pause (UserClosed As Boolean)
    pw.ReleaseKeepAlive
   
End Sub

but now I can not zoom in, so the question is this: I can see the video through the webview1?
 
Upvote 0

FJS

Active Member
Licensed User
Longtime User
Hello everybody,

I am trying to use the following html code:

<script type="text/javascript" src="http://ad.leadboltads.net/show_app_ad.js?section_id=xxxxxxxxx"></script>

As you can see, the idea is showing ads,

with a webview like:

WebView1.LoadHtml("<script type="text/javascript" src="http://ad.leadboltads.net/show_app_ad.js?section_id=xxxxxxxxx"></script>")

however it has a syntax error... and only the text apears:(

Please, any expert could you tell me how white right the information?

Thank you!
 
Upvote 0
Top