incendio Well-Known Member Licensed User Longtime User Oct 26, 2020 #1 Hi guys, I follow this tutorial to download apk file from the B4J server into smartphone. Download huge files with HttpUtils2 Better to use: https://www.b4x.com/android/forum/threads/simple-progress-http-download.127214/#post-796463 The attached project includes a slightly modified version of HttpUtils2 and a new service named DownloadService. The purpose of DownloadService is to make it simple to download files of... www.b4x.com The operation was successful but there was something strange with the downloaded file . The icon of the apk was not displayed, see the attachment file. And when I double clicked this file, the error There was a problem parsing the package raised. If I copied manually the apk to smartphone, the icon from the apk was showed. Here is the code to copied downloded file B4X: Sub dd_Complete(Job As HttpJob) Log("Job completed: " & Job.Success) Dim o As OutputStream o = File.OpenOutput(File.DirDefaultExternal, "Test.apk", False) File.Copy2(Job.GetInputStream,o) Job.Release End Sub I tried to download that file via browser in smartphone & install it, it was OK. So the problem seem in download file or copy from Inputstream to Outputstream. Any idea how to solved this? Attachments Test.jpg 173.6 KB · Views: 429 Last edited: Oct 26, 2020
Hi guys, I follow this tutorial to download apk file from the B4J server into smartphone. Download huge files with HttpUtils2 Better to use: https://www.b4x.com/android/forum/threads/simple-progress-http-download.127214/#post-796463 The attached project includes a slightly modified version of HttpUtils2 and a new service named DownloadService. The purpose of DownloadService is to make it simple to download files of... www.b4x.com The operation was successful but there was something strange with the downloaded file . The icon of the apk was not displayed, see the attachment file. And when I double clicked this file, the error There was a problem parsing the package raised. If I copied manually the apk to smartphone, the icon from the apk was showed. Here is the code to copied downloded file B4X: Sub dd_Complete(Job As HttpJob) Log("Job completed: " & Job.Success) Dim o As OutputStream o = File.OpenOutput(File.DirDefaultExternal, "Test.apk", False) File.Copy2(Job.GetInputStream,o) Job.Release End Sub I tried to download that file via browser in smartphone & install it, it was OK. So the problem seem in download file or copy from Inputstream to Outputstream. Any idea how to solved this?
A Alex_197 Well-Known Member Licensed User Longtime User Oct 26, 2020 #2 1. In the IDE - click on Ctrl+P to clean up the project. 2. Just reboot your phone. 3. It might happens if you are running Android 8 or 9 but trying to upload the B4XPage project. If it's a case - you will get this error. The only option is to upgrade your phone to 10+ Upvote 0
1. In the IDE - click on Ctrl+P to clean up the project. 2. Just reboot your phone. 3. It might happens if you are running Android 8 or 9 but trying to upload the B4XPage project. If it's a case - you will get this error. The only option is to upgrade your phone to 10+
incendio Well-Known Member Licensed User Longtime User Oct 26, 2020 #3 I have tested to download and exe & apk file with the app and download manually via browser in smartphone. With browser, the file size (exe & apk) are exactly the same and it can run on Windows OS/Android without a problem. With the app, the file size are smaller and can't run both on Windows/Android. I think there was a problem with Download file example or copy from Inputstream to Outputstream. Upvote 0
I have tested to download and exe & apk file with the app and download manually via browser in smartphone. With browser, the file size (exe & apk) are exactly the same and it can run on Windows OS/Android without a problem. With the app, the file size are smaller and can't run both on Windows/Android. I think there was a problem with Download file example or copy from Inputstream to Outputstream.
Erel B4X founder Staff member Licensed User Longtime User Oct 27, 2020 #4 Code with File.DirDefaultExternal = broken code. Why aren't you checking that Job.Success is true? I recommend you to start with the simple HttpJob.Download: [B4X] OkHttpUtils2 with Wait For Upvote 0
Code with File.DirDefaultExternal = broken code. Why aren't you checking that Job.Success is true? I recommend you to start with the simple HttpJob.Download: [B4X] OkHttpUtils2 with Wait For
incendio Well-Known Member Licensed User Longtime User Oct 27, 2020 #5 After looking your example, found that I was missing 1 important line which is to close OutputStream. Never work with OutputStream before, don't know that it must be closed. All worked now, thanks. Upvote 0
After looking your example, found that I was missing 1 important line which is to close OutputStream. Never work with OutputStream before, don't know that it must be closed. All worked now, thanks.