0

Example on a quotation form, when an user click on Actions print -> report to print, nothing happen. I tried to override the onLoadRequest in my MainActivity onCreate method:

@Nullable
@Override
public GeckoResult<AllowOrDeny> onLoadRequest(GeckoSession session, GeckoSession.NavigationDelegate.LoadRequest request){
/**After i clicked on action print report for current quotaion, the only url i got is a blob url**/
Log.d("myTag", "Test URL "+request.uri);
/**But GeckoView download didn't accept blob url protocol, example blob:https://myodoo-site.com/7899-8999-9855*/
String dir = "/dhaval_files";
File direct = new File(Environment.getExternalStorageDirectory()
                                + "/dhaval_files");
if (!direct.exists()) 
{
    direct.mkdirs();
}
String filename = Environment.getExternalStorageDirectory()+dir+"/my_test.pdf";
DownloadManager.Request my_request = new DownloadManager.Request(Uri.parse(url));
my_request.setTitle(filename);
                        my_request.allowScanningByMediaScanner();
                        my_request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
                        my_request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename);
Uri uri = Uri.fromFile(new File(filename));
my_request.setDestinationUri(uri);
my_request.setMimeType("application/pdf");
DownloadManager manager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
if(manager!=null) manager.enqueue(my_request);
};

I tried to remove "blob:" in url like that :

String url = request.uri.replace("blob:", "");

I am no have exception, but the file download failed. So i attemped to override onDownload method from WebExtension :

WebExtension.DownloadDelegate ddl = new WebExtension.DownloadDelegate() {
            @Nullable
            @Override
            public GeckoResult<WebExtension.DownloadInitData> onDownload(@NonNull WebExtension source, @NonNull WebExtension.DownloadRequest request) {
                Log.d("tag", "onDownload OVERRIDE: "+request.request.uri);
                return WebExtension.DownloadDelegate.super.onDownload(source, request);
            }
        };

I didn't see my message in logs Finally i tested to use HttpURLConnection for handle blob url request but that's not working.

rudi Ladeon
  • 624
  • 6
  • 11

0 Answers0