Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to work in background (with popup notification if someone tries to share a file) #185

Open
privsecti opened this issue Mar 16, 2022 · 2 comments
Labels
feature request New feature or request

Comments

@privsecti
Copy link

privsecti commented Mar 16, 2022

Describe the feature

Could you add option for the app to work in background?

I've been using it to send files between work profile and main profile, but since v1.9.1 if the app is not in foreground it disconnects from server so switching back and forth between apps does not work anymore.

Describe alternatives you've considered

Using older versions of the app or using from browser will work.

Additional context

No response

@privsecti privsecti added the feature request New feature or request label Mar 16, 2022
@fm-sys
Copy link
Owner

fm-sys commented Mar 16, 2022

Yes, the problem is that android activities aren't designed to run in the background.

One solution might be to create a ViewModel/LiveData backed implementation and start a background service with the same webview instance as soon as the activity is paused. Not sure if this will really work though...

https://medium.com/@nicholas.rose/keeping-webview-state-across-configuration-changes-8e071ee9de86

https://medium.com/@oriharel/how-to-run-javascript-code-in-a-background-service-on-android-8ec1a12ebe92

fm-sys added a commit that referenced this issue Mar 18, 2022
fm-sys added a commit that referenced this issue Mar 21, 2022
@ueen
Copy link
Contributor

ueen commented Jun 25, 2022

Better would be a Foreground Service with a running notification*
On the other hand i'm not really sure its worth it, you can just open the app like once and start sending files, which you would have to do anyway for accepting files.

If you actually do want to pursue this heres a start
1.) create foreground service with notification
https://developer.android.com/guide/components/foreground-services
2.) include webview
https://stackoverflow.com/questions/39038771/calling-javascript-from-service-android
3.) proabably best would be just to run the network.js and connect.js you can be inspired by my firefox addon which is basiclly doing the same (running a stripped down version for the background mode - checkout background.js)
https://github.com/ueen/SnapdropFirefoxAddon
if a file is send the app probably should be opened, but consider restrictions on starting activities
https://developer.android.com/guide/components/activities/background-starts

@fm-sys fm-sys mentioned this issue May 27, 2023
@fm-sys fm-sys changed the title Option to work in background Option to work in background (with popup notification if someone tries to share a file) Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants