Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android O Background Service Limitations

Tags:

android

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?

like image 503
drmrbrewer Avatar asked Aug 04 '17 08:08

drmrbrewer


People also ask

What are IntentService limitations?

IntentService is subject to these restrictionsIntentService is a service, and is therefore subject to the new restrictions on background services. As a result, many apps that rely on IntentService do not work properly when targeting Android 8.0 or higher. For this reason, Android Support Library 26.0.

What is the standard limit of background processes in Android?

There is a option called standard limit which means you want to run about 20 processes in your background. If having problem scroll:How to limit background processes in an android smartphone?

What are background services in Android?

A background service performs an operation that isn't directly noticed by the user. For example, if an app used a service to compact its storage, that would usually be a background service.

What are the limitations of background services?

Background Service Limitations: While an app is idle, there are limits to its use of background services. This does not apply to foreground services, which are more noticeable to the user.

What are the limitations of Android 8?

To lower the chance of these problems, Android 8.0 places limitations on what apps can do while users aren't directly interacting with them. Apps are restricted in two ways: Background Service Limitations: While an app is idle, there are limits to its use of background services.

What are the limitations of an app?

Apps are restricted in two ways: Background Service Limitations: While an app is idle, there are limits to its use of background services. This does not apply to foreground services, which are more noticeable to the user.

What are the limitations of broadcast in Android?

Broadcast Limitations: With limited exceptions, apps cannot use their manifest to register for implicit broadcasts. They can still register for these broadcasts at runtime, and they can use the manifest to register for explicit broadcasts targeted specifically at their app.


1 Answers

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.

like image 53
MatPag Avatar answered Sep 21 '22 01:09

MatPag