Open alexduckmanton opened 7 years ago
Same issue here. I've been struggling with this for a couple of days but couldn't find what's causing the problem. Any progress with this @alexduckmanton ?
Yeah I made a change to the notification to make sure the process doesn't get killed. In Signal.java, instead of showing the notification using notifyManager.notify(NOTIFY_ME_ID, notifyBuilder.build());
, try using startForeground(NOTIFY_ME_ID, notifyBuilder.build());
.
Then you can use stopForeground(true);
instead of notifyManager.cancel(NOTIFY_ME_ID);
to kill the notification and tell Android it doesn't need to keep this process running. stopForeground(false);
will release the foreground process without also clearing the notification.
This solves the problem. You are my hero @alexduckmanton, thanks! I'll prepare a PR to include this change in the repo.
@alexduckmanton @jerodb cool job guys, I'm sorry I really neglected the maintenance of this package. Looking forward for your PR and then I will make a new release with all the other fixes and latests contributions.
is this issue fixed al ready?
It does not seem to be. The audio stops when I kill the app, while it shouldn't. Also it keeps playing when I receive a phone call, which is another problem. Regarding the audio stopping, when I looked at the Java part, it seems to be related to the fact that the current library is using a Bound Service. From what I understand it should use startService at least to start the service, and could bind to it later on (or any preferred way of communicating with the service). Services that are only bound but not 'started', will stop as soon as the activity is destroyed (app killed by the user, killed by the system due to low memory after a few app switches...) Only 'started' services can run indefinitely. More info here: https://developer.android.com/guide/components/bound-services Is anyone currently working on a fix?
Same problem here - trying the startForeground solution. The android module should be rewritten from the ground-up... :(
I agree. I don't have time sadly so I forked the library, fixed this issue and adapted the rest to my specific needs. Someday when I have more time I would be glad to rewrite it cause it's not actually so much hassle, but it won't be before some months that I get the chance to do it.
@graphee-gabriel I tried to apply your commits....
you missed: android:name="com.audioStreaming.SignalService"
in the manifest ;)
Anyway, it seems a little buggy...the stop seems not working, but I will make it work
when i add stopForeground(boolean) appear this issue error: cannot find symbol stopForeground(true); ^ symbol: method stopForeground(boolean)
Hey there,
I've got the library up and running for Android, but I'm having some issues getting the app to continue playing audio in the background.
It will appear to be fine, but after switching between 5 or 6 other apps and leaving mine in the background, eventually the whole app closes down and the audio playback stops. When I bring my app to the foreground, it's as if I'm opening it fresh.
Is there some flag I need to pass to React Native or to the library to keep things running? I've tried playing around with
START_STICKY
insideonStartCommand
of Signal.java, but it doesn't seem to help.Thanks!