Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
magicMirror10693334dWebviews are wierd native constructs. So very possible.
You will have to take a Wakelock for this to work, at minimum. -
adamjkeith266334d@magicMirror I have no idea why the past developer made it like this 😂.
I’m not sure a wakelock would work as that wouldn’t allow the app user to close the app or put the device to sleep, which is one of the requirements of the client. The main problem is web view is paused or stopped when the app is closed, would be easier to just remake the whole application 🤣🤣 not being paid enough to do that though 💰 -
Hazarth9503334dI could be wrong, I have limited experience with Android development. But if you want this, shouldn't you create a Background Service? A dedicated uploader/downloader service that does nothing but sits silently until it gets a command from the app to start upload or download... Once the app triggers the Service it wont stop even if you close the app and even better, even if the phone restarts, you can add automatic recovery to that service on a timer for example, or on launch and/or internet available.
-
adamjkeith266334d@Hazarth Yes that is exactly how it is normally done.
Unfortunately the apk is a web view of a web app, therefore it’s completely separate from the apk file which is what uses Android.app.service.
Technically it is possible to send data from the web app to the apk but that is pointless as that still requires it to be uploaded.
Think of it like this:
- The phone has an apk
- The web interface is on the apk
- The web app is on the web interface. -
adamjkeith266334d@Hazarth I’m starting to think the only solution is to overlay an upload button on top of the web interface which will work like a normal app to keep it running via background services.
-
Hazarth9503334d@adamjkeith Ah, I didn't realize you don't have access to the App code in which the webview is shown... Would there be any way to maybe leverage notifications? That should already be a service too... but yeah, dunno :(
-
adamjkeith266334d@Hazarth I have access to the web app, but not the apk file but the client said it’s just a web view.
They aren’t overly helpful -
MammaNeedHummus4449333dAn option:
Decouple it. Make the website button send your app a unique, onetime URL that the app itself can use to upload the file to in the background.
This way you get around the need for the lite browser to handle the upload behaviour (as it probably doesn't support "background uploads"). This hinges on the given that there's some Android library or framework thing you can use to let your app handle the background uploads instead.
Hope this helps -
CoreFusionX3423333d@adamjkeith
@Hazarth was on the right track, except for one thing.
If you want to absolutely ensure it's gonna run no matter what, it must be a *foreground* service.
Background services can be killed by the OS without prior notice.
This, of course, requires showing a permanent notification, but that's pretty much par for the course of all download managers. -
adamjkeith266333d@CoreFusionX ah ok.
So make it so the actual apk application handles the upload in a foreground service to give it priority and prevent unexpected termination by OS? -
adamjkeith266333d@MammaNeedHummus like when the web button is pressed it sends some code to the app calling a function to allow the user to select the file which the app itself will upload?
That’s a possibility as very small amounts of data can be quickly transferred from the web part to the apk app (such as a single function call). -
CoreFusionX3423333d@adamjkeith
Just send a local intent to your own application, and have your foreground service register it in your manifest, and it will launch automatically.
Related Rants
Is it possible to continue file upload for android default browser without the browser being open?
I’ve been tasked by a company to make it so video and photo files can continue being uploaded from an app even when that app is closed. Slight issue is that the app is just a web viewer that goes to a web app.
I know this is convoluted but would the only way to do that be to overlay an actual upload button over the web view so that I can use androids built in service to do that and make a whole new way for the file to be uploaded to the server?
Surely there must be an easier way.
question
web-app
file-upload
android