#Region Project Attributes
#ApplicationLabel: Ejemplo WebView
#VersionCode: 1
#VersionName: 1.0.0
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
Dim Obj1 As Reflector
End Sub
Sub Globals
Private WView As WebView
Dim WebViewExt As WebViewExtras
Private ActivityParent As JavaObject
Private ime1 As IME
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Activity.LoadLayout("webview")
Activity.Title = "Ejemplo WebView"
WView.Initialize("WView")
WebViewExt.Initialize(WView)
WebViewExt.GetSettings.SetDisplayZoomControls(False)
WebViewExt.ZoomEnabled = False
WebViewExt.ClearCache(True)
Activity.AddView(WView,0,0,100%x,100%y)
'If FirstTime Then
Log("estaconectado: " & isConnected)
If isConnected Then
WView.LoadUrl("http://www.google.com.mx")
Obj1.Target = WebViewExt
Else
Msgbox("Para usar la aplicación necesita conexión a internet.", "Conexión Internet")
ExitApplication
End If
'End If
ime1.Initialize("ime1")
ime1.AddHeightChangedEvent
Dim jo As JavaObject = Activity
jo.RunMethodJO("getContext", Null).RunMethodJO("getWindow", Null).RunMethod("setSoftInputMode", _
Array As Object(0x20))
ActivityParent = jo.RunMethodJO("getParent", Null)
End Sub
Sub IME1_HeightChanged (NewHeight As Int, OldHeight As Int)
CallSubDelayed(Me, "AfterChange")
End Sub
Sub AfterChange
Dim ajo As Panel = Activity
Dim Width As Int = ActivityParent.RunMethod("getMeasuredWidth", Null)
Dim Height As Int = ActivityParent.RunMethod("getMeasuredHeight", Null)
If Width = 0 Or Height = 0 Then Return
ajo.Width = Width 'update the "activity" width and height
ajo.Height = Height
WView.Width = Width
WView.Height =Height
End Sub
Sub isConnected() As Boolean
Dim sSocket As ServerSocket
If sSocket.IsInitialized = False Then
sSocket.Initialize(8080, "sSocket")
sSocket.Close
End If
Dim res As String
res = sSocket.GetMyIP
Log(res)
If sSocket.GetMyIP = "127.0.0.1" Or res.StartsWith("fe80::") Then 'fe80::94c2:c6ff:fe42:b881%dummy0
Return False
Else
Return True
End If
End Sub
Sub Activity_Resume
AfterChange
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then
ExitApplication
End If
Return True
End Sub