Please help when i click on the hyperlink of downloading the file nothing happens please help
B4X:
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
Private cc As ContentChooser
Dim cursor1 As Cursor
End Sub
Sub Globals
Private WebView1 As WebView
Dim rr As Reflector
Dim Dialog As JavaObject
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Dim hold As String
Dim rst As ResumableSub = checkuser(hold)
Wait For(rst) Complete (Result As String)
Log("result: " & Result)
Log(hold)
hold=Result
Log("after sum")
If hold=Null Then
'MsgboxAsync("Please close App Connect Again" ,"SMIS")
Return
End If
If hold="Active" Or hold="Expired" Then
Activity.LoadLayout("Sendlesson")
Activity.Title="Digital Lesson Send"
Dim client As JavaObject
client.InitializeNewInstance(Application.PackageName & ".sendlessondata$MyChromeClient", Null)
Dim jo As JavaObject = WebView1
jo.RunMethod("setWebChromeClient", Array(client))
'WebView1.LoadUrl("http://www.kccug.com/KabojjaApp/LessonsDispalys.aspx")
ProgressDialogShow2("Loading Lessons Please Wait...",False)
Sleep(150)
CreateWV
ProgressDialogHide
End If
End Sub
Sub WebView1_OverrideUrl(Url As String) As Boolean
WebView1.LoadUrl(Url)
Return True 'Return True to make webview1 ignore the link
End Sub
Sub CreateWV
'WebView1.Initialize("myw")
'Activity.AddView(WebView1,0,0,1024,560)
rr.Target = WebView1
rr.Target = rr.RunMethod("getSettings")
rr.RunMethod2("setPluginsEnabled", True, "java.lang.boolean")
WebView1.JavaScriptEnabled = True
WebView1.ZoomEnabled = True
WebView1.Visible = True
WebView1.LoadURL("http://www.kccug.com/KabojjaApp/Sendnotes.aspx")
End Sub
Sub ShowFile_Chooser (FilePathCallback As Object, FileChooserParams As Object)
cc.Initialize("CC")
cc.Show("*/*", "Choose File")
Wait For CC_Result (Success As Boolean, Dir As String, FileName As String)
Dim jo As JavaObject = Me
If Success Then
Log(FileName)
File.Copy(Dir, FileName, Starter.Provider.SharedFolder, "TempFile")
jo.RunMethod("SendResult", Array(Starter.Provider.GetFileUri("TempFile"), FilePathCallback))
Else
jo.RunMethod("SendResult", Array(Null, FilePathCallback))
End If
End Sub
#if Java
import android.webkit.*;
import android.webkit.WebChromeClient.*;
import android.net.*;
public static void SendResult(Uri uri, ValueCallback<Uri[]> filePathCallback) {
if (uri != null)
filePathCallback.onReceiveValue(new Uri[] {uri});
else
filePathCallback.onReceiveValue(null);
}
public static class MyChromeClient extends WebChromeClient {
@Override
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback,
FileChooserParams fileChooserParams) {
processBA.raiseEventFromUI(this, "showfile_chooser", filePathCallback, fileChooserParams);
return true;
}
}
#End If
Sub Activity_Resume
End Sub
Attachments
Last edited: