Skip to content

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

Open

Description

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

Activity

  1. ghost added on Mar 16, 2022
  2. fm-sys commented on Mar 16, 2022

    @fm-sys
    Owner

    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

  3. ueen commented on Jun 25, 2022

    @ueen
    Contributor

    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

  4. changed the title [-]Option to work in background[/-] [+]Option to work in background (with popup notification if someone tries to share a file)[/+] on Jun 16, 2024
  5. fm-sys commented on Jul 27, 2024

    @fm-sys
    Owner

    Marking as won't fix, at least I won't work on it myself cause of potential battery drain and very difficult implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestNew feature or requestwontfixThis will not be worked on

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions