drmrbrewer
drmrbrewer

Reputation: 13049

Android O Background Service Limitations

In the migration guide it is suggested that we use NotificationManager.startServiceInForeground() instead of startService() when necessary.

But I cannot see any startServiceInForeground() method in NotificationManager. What am I missing?

Upvotes: 7

Views: 2926

Answers (3)

MatPag
MatPag

Reputation: 44881

You need to change the API level of documentation site to see the new methods

screenshot

You should use the below method suggested by @RobCo added in the 26.0.0-beta1 support library release

ContextCompat.startForegroundService()

And YES, the migration guide for this is wrong, NotificationManager doesn't have a method called startForegroundService() even in API 26.

PS: The migration guide has been corrected, and now it links correctly to the ContextCompat.startForegroundService() method.

Upvotes: 4

sam_k
sam_k

Reputation: 6023

They haven't changed in the migration guide yet.

You should use ContextCompat.startForegroundService() instead of NotificationManager.startServiceInForeground() method.

Upvotes: 1

mbonnin
mbonnin

Reputation: 7032

You're not missing anything. Looks like google forgot to update the docs.

Upvotes: 0

Related Questions