Android Question How to save file from datatables export

Sofian

Member
I have create php report with datatables script and button export to excel, in normal windows web browser it working to create excel from table on page. But on webview, I got nothing from button export click.
webview url:
WebView1_OverrideUrl
got nothing change on log.

How to get/save file create from datatables button script from webview ?
 

Attachments

  • download export.png
    download export.png
    30.8 KB · Views: 106

aeric

Expert
Licensed User
Longtime User
Upvote 0

Sofian

Member
Changed "box.stl" to "Laporan Transaksi Member.xlsx" and same result from b4xMainPage sample, only show on log progress not firing any BA sub . not to mention change to new class name of B4XPage still blank
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
If you follow all my suggestions above, it should work.
The excel file opens in my WPS app.
 

Attachments

  • DownloadTest3.zip
    22.3 KB · Views: 93
Last edited:
Upvote 0

Sofian

Member
Thanks for sample file, I download and run as it , no modification. It open B4xMainPage with blank n button bellow. click button on first b4xmainpage, it show report page, that load web link . click on button export, and log show :
code:
Logger connected to: b1c5769f
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Initialize => Parent: anywheresoftware.b4a.BA@d7b0989
>>>>>>>> SetupJavaScriptInterface
parent: anywheresoftware.b4a.BA@d7b0989
Javascript Interface 'B4A' Successfully Initialized
>>>>>>>> SetupDownloadListener
setDownloadListener
DownloadListener is done
>>>>>>>> SetupWebChromeClient
>>>>>>>> SetupWebViewSettings
AllowFileAccess: true
AllowContentAccess: true
DomStorageEnabled: true
AllowUniversalAccessFromFileURLs: true
AllowFileAccessFromFileURLs: true
UseWideViewPort: true
JavaScriptCanOpenWindowsAutomatically: true
LoadWithOverviewMode: true
DisplayZoomControls: false
CacheMode: 2
ForceDark: 1
LoadsImagesAutomatically: true
BlockNetworkImage: false
BlockNetworkLoads: false
DefaultTextEncodingName: utf-8
UserAgentString: Mozilla/5.0 (Linux; Android 14; 2107113SG Build/UKQ1.231207.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/135.0.7049.111 Mobile Safari/537.36
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
Progress: 10%
Progress: 21%
Progress: 21%
Progress: 23%
Progress: 38%
Progress: 40%
Progress: 70%
Progress: 73%
Progress: 100%
Progress: 100%
PageFinished: https://dapurhn.swk-apps.com/laporan/
>>>>>>>> ExecuteJavaScript: console.log('PageFinished');
>>>>>>>> js1: console.log('PageFinished');
Progress: 100%
CONSOLE LOG: PageFinished                                                      In  (Line: 1)
contentDisposition: []
Send GET XMLHttpRequest: blob:https://dapurhn.swk-apps.com/a5b8b596-c01f-4e78-b025-d62c7d0c52dc  MimeType: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
>>>>>>>> ExecuteJavaScript: console.log('FOUND Blob URL');
>>>>>>>> js1: console.log('FOUND Blob URL');
>>>>>>>> ExecuteJavaScript: var xhr = new XMLHttpRequest(); xhr.open('GET', 'blob:https://dapurhn.swk-apps.com/a5b8b596-c01f-4e78-b025-d62c7d0c52dc', true); xhr.setRequestHeader('Access-Control-Allow-Origin', true); xhr.setRequestHeader('Content-type','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8'); xhr.responseType = 'blob'; xhr.onload = function(e) {    if (this.status == 200) {        var blobFile = this.response;        var reader = new FileReader();        reader.readAsDataURL(blobFile);        reader.onloadend = function() {           var base64data = reader.result;          B4A.getBase64FromBlobData(base64data);        }    } }; xhr.send(); xhr.onreadystatechange = () => {  if (xhr.readyState === xhr.HEADERS_RECEIVED) {     console.log('>>>>>>>> RECEIVED HEADERS <<<<<<<<');     const headers = xhr.getAllResponseHeaders();     console.log('Headers: ' + JSON.stringify(headers, null, 3));     const arr = headers.trim().split(("\r\n"));     console.log('Header size: ' + arr.length);     const headerArray = [];     arr.forEach((line) => {        headerArray.push(line);     });     var idx = 0;     headerArray.forEach((header) => {        idx++;        console.log('[HEADER ' + idx + '] => ' + header);     });   }};
>>>>>>>> js1: var xhr = new XMLHttpRequest(); xhr.open('GET', 'blob:https://dapurhn.swk-apps.com/a5b8b596-c01f-4e78-b025-d62c7d0c52dc', true); xhr.setRequestHeader('Access-Control-Allow-Origin', true); xhr.setRequestHeader('Content-type','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8'); xhr.responseType = 'blob'; xhr.onload = function(e) {    if (this.status == 200) {        var blobFile = this.response;        var reader = new FileReader();        reader.readAsDataURL(blobFile);        reader.onloadend = function() {           var base64data = reader.result;          B4A.getBase64FromBlobData(base64data);        }    } }; xhr.send(); xhr.onreadystatechange = () => {  if (xhr.readyState === xhr.HEADERS_RECEIVED) {     console.log('>>>>>>>> RECEIVED HEADERS <<<<<<<<');     const headers = xhr.getAllResponseHeaders();     console.log('Headers: ' + JSON.stringify(headers, null, 3));     const arr = headers.trim().split(("\r\n"));     console.log('Header size: ' + arr.length);     const headerArray = [];     arr.forEach((line) => {        headerArray.push(line);     });     var idx = 0;     headerArray.forEach((header) => {        idx++;        console.log('[HEADER ' + idx + '] => ' + header);     });   }};
CONSOLE LOG: FOUND Blob URL                                                      In  (Line: 1)
CONSOLE LOG: >>>>>>>> RECEIVED HEADERS <<<<<<<<                                                      In  (Line: 1)
CONSOLE LOG: Headers: "content-length: 4055\r\ncontent-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\r\n"                                                      In  (Line: 1)
CONSOLE LOG: Header size: 2                                                      In  (Line: 1)
CONSOLE LOG: [HEADER 1] => content-length: 4055                                                      In  (Line: 1)
CONSOLE LOG: [HEADER 2] => content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet                                                      In  (Line: 1)
MimeType ==> application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Extension ==> [xlsx]
Path ==> /storage/emulated/0/Download/May_7_2025_18-16-24.xlsx
regex ==> ^data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,
BASE64 DATA: UEsDBAoAAAAAAAxap1oAAAAAAAAAAA ... and more ...
** Activity (main) Pause event (activity is not paused). **
** Service (starter) Destroy (ignored)**
** Activity (main) Resume **
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
** Activity (main) Pause event (activity is not paused). **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
*** Receiver (firebasemessaging) Receive (first time) ***
*** Receiver (httputils2service) Receive (first time) ***
:frmbrowser,18
java.lang.ClassNotFoundException: com.android.webview.chromium.ContentSettingsAdapter
    at java.lang.Class.classForName(Native Method)
    at java.lang.Class.forName(Class.java:607)
    at java.lang.Class.forName(Class.java:512)
    at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:321)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:120)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
    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 anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
    at swk.dapur.hanarasa.frmbrowser._b4xpage_created(frmbrowser.java:66)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
    at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:285)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1087)
    at swk.dapur.hanarasa.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:1078)
    at swk.dapur.hanarasa.b4xpagesmanager._showpage(b4xpagesmanager.java:510)
    at swk.dapur.hanarasa.b4xpages._showpage(b4xpages.java:52)
    at swk.dapur.hanarasa.b4xmainpage._clvx2_itemclick(b4xmainpage.java:1523)
    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 anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1114)
    at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:1077)
    at b4a.example3.customlistview$ResumableSub_PanelClickHandler.resume(customlistview.java:805)
    at b4a.example3.customlistview._panelclickhandler(customlistview.java:748)
    at b4a.example3.customlistview._panel_click(customlistview.java:735)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:7798)
    at android.view.View.performClickInternal(View.java:7775)
    at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
    at android.view.View$PerformClick.run(View.java:31225)
    at android.os.Handler.handleCallback(Handler.java:958)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:224)
    at android.os.Looper.loop(Looper.java:318)
    at android.app.ActivityThread.main(ActivityThread.java:8790)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:561)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
Caused by: java.lang.ClassNotFoundException: com.android.webview.chromium.ContentSettingsAdapter
    ... 49 more
** Activity (main) Resume **
** Activity (main) Pause event (activity is not paused). **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
*** Receiver (firebasemessaging) Receive (first time) ***
*** Receiver (httputils2service) Receive (first time) ***
** Activity (main) Resume **
:frmbrowser,19
java.lang.ClassNotFoundException: com.android.webview.chromium.ContentSettingsAdapter
    at java.lang.Class.classForName(Native Method)
    at java.lang.Class.forName(Class.java:607)
    at java.lang.Class.forName(Class.java:512)
    at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:321)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:120)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
    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 anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
    at swk.dapur.hanarasa.frmbrowser._b4xpage_created(frmbrowser.java:66)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
    at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:285)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1087)
    at swk.dapur.hanarasa.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:1078)
    at swk.dapur.hanarasa.b4xpagesmanager._showpage(b4xpagesmanager.java:510)
    at swk.dapur.hanarasa.b4xpages._showpage(b4xpages.java:52)
    at swk.dapur.hanarasa.b4xmainpage._clvx2_itemclick(b4xmainpage.java:1523)
    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 anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1114)
    at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:1077)
    at b4a.example3.customlistview$ResumableSub_PanelClickHandler.resume(customlistview.java:805)
    at b4a.example3.customlistview._panelclickhandler(customlistview.java:748)
    at b4a.example3.customlistview._panel_click(customlistview.java:735)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:7798)
    at android.view.View.performClickInternal(View.java:7775)
    at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
    at android.view.View$PerformClick.run(View.java:31225)
    at android.os.Handler.handleCallback(Handler.java:958)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:224)
    at android.os.Looper.loop(Looper.java:318)
    at android.app.ActivityThread.main(ActivityThread.java:8790)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:561)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
Caused by: java.lang.ClassNotFoundException: com.android.webview.chromium.ContentSettingsAdapter
    ... 49 more
** Activity (main) Resume **
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
** Activity (main) Pause event (activity is not paused). **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
*** Receiver (firebasemessaging) Receive (first time) ***
*** Receiver (httputils2service) Receive (first time) ***
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
:frmbrowser,18
java.lang.ClassNotFoundException: com.android.webview.chromium.ContentSettingsAdapter
    at java.lang.Class.classForName(Native Method)
    at java.lang.Class.forName(Class.java:607)
    at java.lang.Class.forName(Class.java:512)
    at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:321)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:120)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
    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 anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
    at swk.dapur.hanarasa.frmbrowser._b4xpage_created(frmbrowser.java:66)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
    at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:285)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1087)
    at swk.dapur.hanarasa.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:1078)
    at swk.dapur.hanarasa.b4xpagesmanager._showpage(b4xpagesmanager.java:510)
    at swk.dapur.hanarasa.b4xpages._showpage(b4xpages.java:52)
    at swk.dapur.hanarasa.b4xmainpage._clvx2_itemclick(b4xmainpage.java:1523)
    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 anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1114)
    at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:1077)
    at b4a.example3.customlistview$ResumableSub_PanelClickHandler.resume(customlistview.java:805)
    at b4a.example3.customlistview._panelclickhandler(customlistview.java:748)
    at b4a.example3.customlistview._panel_click(customlistview.java:735)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:7798)
    at android.view.View.performClickInternal(View.java:7775)
    at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
    at android.view.View$PerformClick.run(View.java:31225)
    at android.os.Handler.handleCallback(Handler.java:958)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:224)
    at android.os.Looper.loop(Looper.java:318)
    at android.app.ActivityThread.main(ActivityThread.java:8790)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:561)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
Caused by: java.lang.ClassNotFoundException: com.android.webview.chromium.ContentSettingsAdapter
    ... 49 more
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
*** mainpage: B4XPage_Created
*** mainpage: B4XPage_Appear
** Activity (main) Resume **
*** report: B4XPage_Created [mainpage]
Initialize => Parent: anywheresoftware.b4a.BA@9444c54
>>>>>>>> SetupJavaScriptInterface
parent: anywheresoftware.b4a.BA@9444c54
Javascript Interface 'B4A' Successfully Initialized
>>>>>>>> SetupDownloadListener
setDownloadListener
DownloadListener is done
>>>>>>>> SetupWebChromeClient
>>>>>>>> SetupWebViewSettings
AllowFileAccess: true
AllowContentAccess: true
DomStorageEnabled: true
AllowUniversalAccessFromFileURLs: true
AllowFileAccessFromFileURLs: true
UseWideViewPort: true
JavaScriptCanOpenWindowsAutomatically: true
LoadWithOverviewMode: true
DisplayZoomControls: false
CacheMode: 2
ForceDark: 1
LoadsImagesAutomatically: true
BlockNetworkImage: false
BlockNetworkLoads: false
DefaultTextEncodingName: utf-8
UserAgentString: Mozilla/5.0 (Linux; Android 14; 2107113SG Build/UKQ1.231207.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/135.0.7049.111 Mobile Safari/537.36
*** mainpage: B4XPage_Disappear [mainpage]
*** report: B4XPage_Appear [mainpage]
Progress: 10%
Progress: 21%
Progress: 25%
Progress: 48%
Progress: 56%
Progress: 70%
Progress: 73%
Progress: 84%
Progress: 100%
Progress: 100%
PageFinished: https://dapurhn.swk-apps.com/laporan/
>>>>>>>> ExecuteJavaScript: console.log('PageFinished');
Progress: 100%
CONSOLE LOG: PageFinished                                                      In  (Line: 1)
contentDisposition: []
Send GET XMLHttpRequest: blob:https://dapurhn.swk-apps.com/20f2ca1e-1090-493c-8cf2-f8dc4b0cfcde  MimeType: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
>>>>>>>> ExecuteJavaScript: console.log('FOUND Blob URL');
>>>>>>>> ExecuteJavaScript: var xhr = new XMLHttpRequest(); xhr.open('GET', 'blob:https://dapurhn.swk-apps.com/20f2ca1e-1090-493c-8cf2-f8dc4b0cfcde', true); xhr.setRequestHeader('Access-Control-Allow-Origin', true); xhr.setRequestHeader('Content-type','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8'); xhr.responseType = 'blob'; xhr.onload = function(e) {    if (this.status == 200) {        var blobFile = this.response;        var reader = new FileReader();        reader.readAsDataURL(blobFile);        reader.onloadend = function() {           var base64data = reader.result;          B4A.getBase64FromBlobData(base64data);        }    } }; xhr.send(); xhr.onreadystatechange = () => {  if (xhr.readyState === xhr.HEADERS_RECEIVED) {     console.log('>>>>>>>> RECEIVED HEADERS <<<<<<<<');     const headers = xhr.getAllResponseHeaders();     console.log('Headers: ' + JSON.stringify(headers, null, 3));     const arr = headers.trim().split(("\r\n"));     console.log('Header size: ' + arr.length);     const headerArray = [];     arr.forEach((line) => {        headerArray.push(line);     });     var idx = 0;     headerArray.forEach((header) => {        idx++;        console.log('[HEADER ' + idx + '] => ' + header);     });   }};
CONSOLE LOG: FOUND Blob URL                                                      In  (Line: 1)
CONSOLE LOG: >>>>>>>> RECEIVED HEADERS <<<<<<<<                                                      In  (Line: 1)
CONSOLE LOG: Headers: "content-length: 4055\r\ncontent-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\r\n"                                                      In  (Line: 1)
CONSOLE LOG: Header size: 2                                                      In  (Line: 1)
CONSOLE LOG: [HEADER 1] => content-length: 4055                                                      In  (Line: 1)
CONSOLE LOG: [HEADER 2] => content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet                                                      In  (Line: 1)
BASE64 DATA: UEsDBAoAAAAAALFcp1oAAAAAAAAAAA ... and more ...
contentDisposition: []
Send GET XMLHttpRequest: blob:https://dapurhn.swk-apps.com/fc70dac5-6f97-4538-a45f-65a5df8ebd80  MimeType: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
>>>>>>>> ExecuteJavaScript: console.log('FOUND Blob URL');
>>>>>>>> ExecuteJavaScript: var xhr = new XMLHttpRequest(); xhr.open('GET', 'blob:https://dapurhn.swk-apps.com/fc70dac5-6f97-4538-a45f-65a5df8ebd80', true); xhr.setRequestHeader('Access-Control-Allow-Origin', true); xhr.setRequestHeader('Content-type','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8'); xhr.responseType = 'blob'; xhr.onload = function(e) {    if (this.status == 200) {        var blobFile = this.response;        var reader = new FileReader();        reader.readAsDataURL(blobFile);        reader.onloadend = function() {           var base64data = reader.result;          B4A.getBase64FromBlobData(base64data);        }    } }; xhr.send(); xhr.onreadystatechange = () => {  if (xhr.readyState === xhr.HEADERS_RECEIVED) {     console.log('>>>>>>>> RECEIVED HEADERS <<<<<<<<');     const headers = xhr.getAllResponseHeaders();     console.log('Headers: ' + JSON.stringify(headers, null, 3));     const arr = headers.trim().split(("\r\n"));     console.log('Header size: ' + arr.length);     const headerArray = [];     arr.forEach((line) => {        headerArray.push(line);     });     var idx = 0;     headerArray.forEach((header) => {        idx++;        console.log('[HEADER ' + idx + '] => ' + header);     });   }};
CONSOLE LOG: FOUND Blob URL                                                      In  (Line: 1)
CONSOLE LOG: >>>>>>>> RECEIVED HEADERS <<<<<<<<                                                      In  (Line: 1)
CONSOLE LOG: Headers: "content-length: 4055\r\ncontent-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\r\n"                                                      In  (Line: 1)
CONSOLE LOG: Header size: 2                                                      In  (Line: 1)
CONSOLE LOG: [HEADER 1] => content-length: 4055                                                      In  (Line: 1)
CONSOLE LOG: [HEADER 2] => content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet                                                      In  (Line: 1)
BASE64 DATA: UEsDBAoAAAAAALhcp1oAAAAAAAAAAA ... and more ...
** Activity (main) Pause event (activity is not paused). **
*** report: B4XPage_Disappear [mainpage, report]
** Service (starter) Destroy (ignored)**
** Activity (main) Resume **
*** report: B4XPage_Appear [mainpage, report]
contentDisposition: []
Send GET XMLHttpRequest: blob:https://dapurhn.swk-apps.com/d678f6fe-14f5-4eb2-9260-bd18ba8529d5  MimeType: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
>>>>>>>> ExecuteJavaScript: console.log('FOUND Blob URL');
>>>>>>>> ExecuteJavaScript: var xhr = new XMLHttpRequest(); xhr.open('GET', 'blob:https://dapurhn.swk-apps.com/d678f6fe-14f5-4eb2-9260-bd18ba8529d5', true); xhr.setRequestHeader('Access-Control-Allow-Origin', true); xhr.setRequestHeader('Content-type','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8'); xhr.responseType = 'blob'; xhr.onload = function(e) {    if (this.status == 200) {        var blobFile = this.response;        var reader = new FileReader();        reader.readAsDataURL(blobFile);        reader.onloadend = function() {           var base64data = reader.result;          B4A.getBase64FromBlobData(base64data);        }    } }; xhr.send(); xhr.onreadystatechange = () => {  if (xhr.readyState === xhr.HEADERS_RECEIVED) {     console.log('>>>>>>>> RECEIVED HEADERS <<<<<<<<');     const headers = xhr.getAllResponseHeaders();     console.log('Headers: ' + JSON.stringify(headers, null, 3));     const arr = headers.trim().split(("\r\n"));     console.log('Header size: ' + arr.length);     const headerArray = [];     arr.forEach((line) => {        headerArray.push(line);     });     var idx = 0;     headerArray.forEach((header) => {        idx++;        console.log('[HEADER ' + idx + '] => ' + header);     });   }};
CONSOLE LOG: FOUND Blob URL                                                      In  (Line: 1)
CONSOLE LOG: >>>>>>>> RECEIVED HEADERS <<<<<<<<                                                      In  (Line: 1)
CONSOLE LOG: Headers: "content-length: 4055\r\ncontent-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\r\n"                                                      In  (Line: 1)
CONSOLE LOG: Header size: 2                                                      In  (Line: 1)
CONSOLE LOG: [HEADER 1] => content-length: 4055                                                      In  (Line: 1)
CONSOLE LOG: [HEADER 2] => content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet                                                      In  (Line: 1)
BASE64 DATA: UEsDBAoAAAAAAOVcp1oAAAAAAAAAAA ... and more ...

like U see, I click it 3 times. where the files downloaded ? how I open it ?
 
Upvote 0

Sofian

Member
Stragely, I copy your code on my apps, it working . this is log:
code:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
*** Receiver (firebasemessaging) Receive (first time) ***
*** Receiver (httputils2service) Receive (first time) ***
Initialize => Parent: anywheresoftware.b4a.ShellBA@f8e2542
>>>>>>>> SetupJavaScriptInterface
parent: anywheresoftware.b4a.ShellBA@f8e2542
Javascript Interface 'B4A' Successfully Initialized
>>>>>>>> SetupDownloadListener
setDownloadListener
DownloadListener is done
>>>>>>>> SetupWebChromeClient
>>>>>>>> SetupWebViewSettings
AllowFileAccess: true
AllowContentAccess: true
DomStorageEnabled: true
AllowUniversalAccessFromFileURLs: true
AllowFileAccessFromFileURLs: true
UseWideViewPort: true
JavaScriptCanOpenWindowsAutomatically: true
LoadWithOverviewMode: true
DisplayZoomControls: false
CacheMode: 2
ForceDark: 1
LoadsImagesAutomatically: true
BlockNetworkImage: false
BlockNetworkLoads: false
DefaultTextEncodingName: utf-8
UserAgentString: Mozilla/5.0 (Linux; Android 14; 2107113SG Build/UKQ1.231207.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/135.0.7049.111 Mobile Safari/537.36
Progress: 10%
Progress: 21%
Progress: 22%
Progress: 24%
Progress: 57%
Progress: 70%
Progress: 73%
Progress: 100%
PageFinished: https://dapurhn.swk-apps.com/laporan/
>>>>>>>> ExecuteJavaScript: console.log('PageFinished');
Progress: 100%
CONSOLE LOG: PageFinished                                                      In  (Line: 1)
contentDisposition: []
Send GET XMLHttpRequest: blob:https://dapurhn.swk-apps.com/e91d3b02-0f5e-46cf-91fa-8f69135ab67a  MimeType: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
>>>>>>>> ExecuteJavaScript: console.log('FOUND Blob URL');
>>>>>>>> ExecuteJavaScript: var xhr = new XMLHttpRequest(); xhr.open('GET', 'blob:https://dapurhn.swk-apps.com/e91d3b02-0f5e-46cf-91fa-8f69135ab67a', true); xhr.setRequestHeader('Access-Control-Allow-Origin', true); xhr.setRequestHeader('Content-type','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8'); xhr.responseType = 'blob'; xhr.onload = function(e) {    if (this.status == 200) {        var blobFile = this.response;        var reader = new FileReader();        reader.readAsDataURL(blobFile);        reader.onloadend = function() {           var base64data = reader.result;          B4A.getBase64FromBlobData(base64data);        }    } }; xhr.send(); xhr.onreadystatechange = () => {  if (xhr.readyState === xhr.HEADERS_RECEIVED) {     console.log('>>>>>>>> RECEIVED HEADERS <<<<<<<<');     const headers = xhr.getAllResponseHeaders();     console.log('Headers: ' + JSON.stringify(headers, null, 3));     const arr = headers.trim().split(("\r\n"));     console.log('Header size: ' + arr.length);     const headerArray = [];     arr.forEach((line) => {        headerArray.push(line);     });     var idx = 0;     headerArray.forEach((header) => {        idx++;        console.log('[HEADER ' + idx + '] => ' + header);     });   }};
Url: blob:https://dapurhn.swk-apps.com/e91d3b02-0f5e-46cf-91fa-8f69135ab67a
UserAgent: Mozilla/5.0 (Linux; Android 14; 2107113SG Build/UKQ1.231207.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/135.0.7049.111 Mobile Safari/537.36
ContentDisposition:
ContentType: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
ContentLength: 4055 Bytes
[BLOB] URL: blob:https://dapurhn.swk-apps.com/e91d3b02-0f5e-46cf-91fa-8f69135ab67a
CONSOLE LOG: FOUND Blob URL                                                      In  (Line: 1)
CONSOLE LOG: >>>>>>>> RECEIVED HEADERS <<<<<<<<                                                      In  (Line: 1)
CONSOLE LOG: Headers: "content-length: 4055\r\ncontent-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\r\n"                                                      In  (Line: 1)
CONSOLE LOG: Header size: 2                                                      In  (Line: 1)
CONSOLE LOG: [HEADER 1] => content-length: 4055                                                      In  (Line: 1)
CONSOLE LOG: [HEADER 2] => content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet                                                      In  (Line: 1)
BASE64 DATA: UEsDBAoAAAAAADxep1oAAAAAAAAAAA ... and more ...
BLOB FILE SAVED: Laporan Transaksi Member.xlsx     Size: 4055 Bytes
PK
����������<^�Z������������������������������_rels/PK
��������<^�Z��닮������'����������_rels/.rels����0�WYz��c��1�j��
... and more ...
 
LISTING FILES ON DIR.INTERNAL:/data/user/0/swk.dapur.hanarasa/files
FILE: generatefid.lock     Size: 0 Bytes
FILE: as_settings.db-journal     Size: 512 Bytes
FILE: as_settings.db     Size: 16384 Bytes
FILE: PersistedInstallation.W0RFRkFVTFRd+MToxMTE3NDA0NzUyMTg6YW5kcm9pZDowOTYyYTdkOTZkODkwYzI2ZGIwYzhi.json     Size: 567 Bytes
FILE: 1741970706762.png     Size: 32831 Bytes
FILE: 1741970678842.png     Size: 32831 Bytes
FILE: 1741970664422.png     Size: 32831 Bytes
FILE: image.png     Size: 2523563 Bytes
DIR/: virtual_assets
DIR/: shared
FILE: Laporan Transaksi Member.xlsx     Size: 4055 Bytes
 
RETURNED FROM DownloadAndSaveFile. Success: true
INTENT URI: content:///storage/emulated/0/Download/Laporan Transaksi Member.xlsx
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
** Activity (main) Pause event (activity is not paused). **
** Service (starter) Destroy (ignored)**
It show open with, I choose excel reader and nothing happen, I cant find the xlsx file with file explore either.
 
Upvote 0

Sofian

Member
I confirm it success download the files and save it on :
code:
INTENT URI: content:///storage/emulated/0/Download/Laporan Transaksi Member.xlsx

I think it must use file sharring or something copy it to serviceprovider shared folder ?
 
Upvote 0

Sofian

Member
I confirm it success download the files and save it on :
code:
INTENT URI: content:///storage/emulated/0/Download/Laporan Transaksi Member.xlsx

I think it must use file sharring or something copy it to serviceprovider shared folder ?
and more confusing, if run on debug mode it can catch download, on release mode it not catch anything, as I run Your code (release mode) and that run well on my code (on debug mode) if I change my app to release , nothing happen with click export button. Log show :
code:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
*** Receiver (httputils2service) Receive (first time) ***
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
*** Receiver (firebasemessaging) Receive (first time) ***
Initialize => Parent: anywheresoftware.b4a.BA@6f00be1
>>>>>>>> SetupJavaScriptInterface
parent: anywheresoftware.b4a.BA@6f00be1
Javascript Interface 'B4A' Successfully Initialized
>>>>>>>> SetupDownloadListener
setDownloadListener
DownloadListener is done
>>>>>>>> SetupWebChromeClient
>>>>>>>> SetupWebViewSettings
AllowFileAccess: true
AllowContentAccess: true
DomStorageEnabled: true
AllowUniversalAccessFromFileURLs: true
AllowFileAccessFromFileURLs: true
UseWideViewPort: true
JavaScriptCanOpenWindowsAutomatically: true
LoadWithOverviewMode: true
DisplayZoomControls: false
CacheMode: 2
ForceDark: 1
LoadsImagesAutomatically: true
BlockNetworkImage: false
BlockNetworkLoads: false
DefaultTextEncodingName: utf-8
UserAgentString: Mozilla/5.0 (Linux; Android 14; 2107113SG Build/UKQ1.231207.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/135.0.7049.111 Mobile Safari/537.36
Progress: 10%
Progress: 21%
Progress: 21%
Progress: 27%
Progress: 34%
Progress: 36%
Progress: 70%
Progress: 74%
Progress: 100%
PageFinished: https://dapurhn.swk-apps.com/laporan/
>>>>>>>> ExecuteJavaScript: console.log('PageFinished');
Progress: 100%
CONSOLE LOG: PageFinished                                                      In  (Line: 1)
contentDisposition: []
Send GET XMLHttpRequest: blob:https://dapurhn.swk-apps.com/ee1282e9-6173-4606-a9a5-1384df6b853a  MimeType: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
>>>>>>>> ExecuteJavaScript: console.log('FOUND Blob URL');
>>>>>>>> ExecuteJavaScript: var xhr = new XMLHttpRequest(); xhr.open('GET', 'blob:https://dapurhn.swk-apps.com/ee1282e9-6173-4606-a9a5-1384df6b853a', true); xhr.setRequestHeader('Access-Control-Allow-Origin', true); xhr.setRequestHeader('Content-type','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8'); xhr.responseType = 'blob'; xhr.onload = function(e) {    if (this.status == 200) {        var blobFile = this.response;        var reader = new FileReader();        reader.readAsDataURL(blobFile);        reader.onloadend = function() {           var base64data = reader.result;          B4A.getBase64FromBlobData(base64data);        }    } }; xhr.send(); xhr.onreadystatechange = () => {  if (xhr.readyState === xhr.HEADERS_RECEIVED) {     console.log('>>>>>>>> RECEIVED HEADERS <<<<<<<<');     const headers = xhr.getAllResponseHeaders();     console.log('Headers: ' + JSON.stringify(headers, null, 3));     const arr = headers.trim().split(("\r\n"));     console.log('Header size: ' + arr.length);     const headerArray = [];     arr.forEach((line) => {        headerArray.push(line);     });     var idx = 0;     headerArray.forEach((header) => {        idx++;        console.log('[HEADER ' + idx + '] => ' + header);     });   }};
CONSOLE LOG: FOUND Blob URL                                                      In  (Line: 1)
CONSOLE LOG: >>>>>>>> RECEIVED HEADERS <<<<<<<<                                                      In  (Line: 1)
CONSOLE LOG: Headers: "content-length: 4055\r\ncontent-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\r\n"                                                      In  (Line: 1)
CONSOLE LOG: Header size: 2                                                      In  (Line: 1)
CONSOLE LOG: [HEADER 1] => content-length: 4055                                                      In  (Line: 1)
CONSOLE LOG: [HEADER 2] => content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet                                                      In  (Line: 1)
BASE64 DATA: UEsDBAoAAAAAAJRsp1oAAAAAAAAAAA ... and more ...

on debug mode, it show like post #24
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I download and run as it , no modification.
I don't like dishonest people.

If you think I don't know.
*** Receiver (firebasemessaging) Receive (first time) ***
*** Receiver (httputils2service) Receive (first time) ***
:frmbrowser,18
The logs shows this is not my code.

It open B4xMainPage with blank n button bellow. click button on first b4xmainpage, it show report page, that load web link .
This is expected. The WebView already moved from B4XMainPage layout to a new B4XPage layout as you wished.
B4XMainPage only has a button to open the new Page.
The new B4XPage has a WebView that loads the url.

Sorry, I don't want to help anymore and work with people with such attitude.
 
Upvote 0

Sofian

Member
I willy not modified your code there, I cant force you to believe or not.. I that have problem and you help me, what I get for dishonest ?
Sorry if you think soo, and thank a lot for Your help
Maybe I try alot this and that code that I can get from sample, I honestly not be purpose dishonest here if that what U mean.
 
Upvote 0

Sofian

Member
I want to clear some missandertanding here, I now why it show log not from you code, I open 2 window code , 1 is from My project and 1 from your, if I run my project, the log file can show on your code log isnt it ? that how it mix when I copy your code log file, it show part of my project code log. That what I can explain for U, if you still think I dishonest, its up to you, but Im not.
 
Upvote 0

Sofian

Member
code:
*** Receiver (firebasemessaging) Receive (first time) ***
*** Receiver (httputils2service) Receive (first time) ***
:frmbrowser,18
and this part obbiously from my project log, I has inspected your code and even not enable #BridgeLogger, there for log pure from java log bellow. And last but not least :
I never modified your sample code , I run as it is and honestly show log file to you, if it has mistaken copy and paste , mix with my project log because I trial some other B4A project windows code with enable #BridgeLogger, Im sorry for that U think I dishonest. Thats not on purpose.
 
Upvote 0
Top