question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Foreground-Notification does not work after app start

See original GitHub issue

if i call FileDownloader.getImpl().startForeground() for the first time after app start, i get sometimes this:

W/FileDownloader.DownloadServiceNotConnectedHelper: request set the download service as the 
foreground service([354],[Notification(pri=2 contentView=null vibrate=null sound=null 
defaults=0x4 flags=0x3 color=0x00000000 actions=1 vis=PRIVATE)]), but the download service 
isn't connected yet.

is it necessary to issue the start() command of e.g. a FileDownloadQueueSet before to make sure the service is started? currently i call first startForeground() as i want to display the notification already, where in the meanwhile i’m fetching the download urls and starting the actual download after i get the download-url response.

if i then issue a second download afterwards, the notification works properly.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9

github_iconTop GitHub Comments

2reactions
Jacksgongcommented, Sep 22, 2016

I have an idea to make you do that easier, like below two pattern:

/** If the FileDownloader service isn't start and connected yet, will
 * block the thread to start service the connected to it, after connected
 * unblock the thread, and invoke startForeground(Notification); If the
 * FileDownloader service has already started and connected, just invoke
 * startForeground(Notification).
 */
FileDownloader.insureServiceBind().startForeground(Notification):void

/** If the FileDownloader service isn't start and connected yet, will start
 * and connecte to it asynchronous and return false, after connected to the 
 * service, invoke startForeground(Notification); If the FileDownloader 
 * service has already started and connected, just invoke 
 * startForeground(Notification) and return true.
 */
FileDownloader.insureServiceBindAsync().startForeground(Notification):boolean
0reactions
Jacksgongcommented, Sep 22, 2016

Sorry, It does not make sense because startForeground need a customize notification

Read more comments on GitHub >

github_iconTop Results From Across the Web

Notification Doesn't work in the foreground - Stack Overflow
The msg sent from server has to be sent in either "notification" or "data" format, from dashboard or server side api. Note: From...
Read more >
Foreground Notifications are not working · Issue #525 - GitHub
Unable to receive foreground notifications on Android( didn't test on iOS ) with OS 10. When app is minimized the notifications are working....
Read more >
Foreground services - Android Developers
A music player app that plays music in a foreground service. The notification might show the current song that is being played. ·...
Read more >
Foreground service - Microsoft Q&A
The app starts without problems and when I start the foreground service, the notification appears, the service works without problems even when ......
Read more >
Handling Notifications and Notification-Related Actions
A notification that arrives when your app is running in the foreground. A silent notification (see Pushing Background Updates to Your App).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found