Skip to content

Start a foreground service to be able to get audio on Android 11 bg #321

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

Merged
merged 4 commits into from
Nov 23, 2020

Conversation

manuquentin
Copy link
Contributor

Refs #274

Thanks @grit96 for the patch !

Review/feedback are welcome for this one.

@sboily sboily changed the title Start a foreground service to ba able to get audio on Android 11 bg Start a foreground service to be able to get audio on Android 11 bg Nov 23, 2020
@sboily
Copy link
Member

sboily commented Nov 23, 2020

This issue is only if you compile your application with the android 11 SDK. Are you agree @manuquentin?

@danjenkins
Copy link
Collaborator

Oh this would make sense as to why my apps have all continued working @sboily (if thats the case)

@sboily
Copy link
Member

sboily commented Nov 23, 2020

I made test and if i'm using my application with the SDK 29 on my android 11, i have no issue. But if i compile with the SDK 30, i reproduce this issue.

@geraintwhite
Copy link
Contributor

geraintwhite commented Nov 23, 2020

I just tested this and reproduce the issue (without my patch applied) against both SDK 29 and SDK 30 on Android 11 (Pixel 4).

@sboily
Copy link
Member

sboily commented Nov 23, 2020

Strange i don't reproduce that. My application works without any issues on pixel 3 and 5 with old SDK.

@geraintwhite
Copy link
Contributor

Yes it is strange. I ditched my patch and ran my app with this branch and it works well! The only suggestion I'd add is the ability to specify a notification icon.

@sboily
Copy link
Member

sboily commented Nov 23, 2020

Ok well, my mistake, i receive the audio, but nothing go out from the app!

@sboily
Copy link
Member

sboily commented Nov 23, 2020

@grit96 have you tried with this PR? Is it ok for you?

@geraintwhite
Copy link
Contributor

@sboily yes, tested the PR and it works.

I think we need to use if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { because foreground services are only needed on SDK 28 and above (https://developer.android.com/guide/components/foreground-services).

I also suggested adding the ability to set the notification icon.

@manuquentin
Copy link
Contributor Author

Thanks @grit96 I've added a check on the Android version and added the ability to set the smallIcon (not tested as I don't see the notification on Pixel 3...)
@sboily has tested it. If you're OK with it we can merge this PR

@geraintwhite
Copy link
Contributor

Thanks @manuquentin, it works great! I guess the only thing left is to add docs for the icon.

@manuquentin manuquentin merged commit 619fb95 into master Nov 23, 2020
@manuquentin manuquentin deleted the android_11_foreground_service branch November 23, 2020 19:23
@Kelt Kelt mentioned this pull request Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants