Android Question WebView issue

cantuma1

New Member
Hello to all i am using webview in an app to view the site: https://helpman.komtera.lt/chessocr/
If I use it in a browser there is no problem and it accesses the phone's internal files correctly. If I launch it via webview into the APP nothing happens. the site displays, but does not access to the internal file files or camera. Below th code i used:

#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'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
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.

End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
Private rt As RuntimePermissions
Private WebView1 As WebView

Private WbE As WebViewExtras

Private ChromeCLient As DefaultWebChromeClient

End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
' Attività di creazione
' Richiedi i permessi all'utente per la fotocamera e l'accesso ai file interni del telefono

For Each permission As String In Array(rt.PERMISSION_CAMERA,rt.PERMISSION_ACCESS_FINE_LOCATION,rt.PERMISSION_ACCESS_COARSE_LOCATION,rt.PERMISSION_PROCESS_OUTGOING_CALLS,rt.PERMISSION_WRITE_EXTERNAL_STORAGE,rt.PERMISSION_READ_EXTERNAL_STORAGE)
rt.CheckAndRequest(permission)
Wait For Activity_PermissionResult(permission As String, Result As Boolean)
If Result = False Then
ToastMessageShow("No permission!", True)
'Activity.Finish
Return
End If
Next

ChromeCLient.Initialize("ChromeCLient")
WbE.Initialize(WebView1)
'Hacemos cosas
WbE.SetWebChromeClient(ChromeCLient)


WebView1.JavaScriptEnabled = True
WbE.addJavascriptInterface(WebView1, "B4A")
WebView1.LoadUrl("https://helpman.komtera.lt/chessocr")
' Aggiungi la WebView all'attività
'Activity.AddView(WebView1, 0, 0, 100%x, 100%y)

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click
'WebView1.LoadUrl("https://helpman.komtera.lt/chessocr")
'WebView1.LoadUrl("https://www.google.it")
End Sub
 

drgottjr

Expert
Licensed User
Longtime User
refer to this link: https://www.b4x.com/android/forum/threads/upload-files-with-webview.98623/
there are some very specific steps required for uploading files with a webview.
in addition:
1) replace url in example with url you are using.
2) replace name of file ("TempFile") with "tempfile.png" or "tempfile.jpg" (according to format you wish to upload). this is important.

upload will work (as you will see), but there is a problem with website (error 502).
when i visit site with desktop browser and upload a file, the same error occurs, so it has nothing to do with webview. i attach an image from desktop browser. same error occurred with webview (2 images from device attached).

note: please use
B4X:
tags when showing your code.
 

Attachments

  • chess.png
    chess.png
    42.1 KB · Views: 121
  • app1.png
    app1.png
    16.1 KB · Views: 108
  • app2.png
    app2.png
    16.4 KB · Views: 110
Last edited:
Upvote 0

cantuma1

New Member
Hi dtgottjr, thanks you very much for your answer. Very strange the site give me the same error, but till last week there was not problem.
i'll chech with another web site. thanks a lot again

Marco
 
Upvote 0
Top