Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android O Settings to enable background restriction for applications

As per the Docs-

Note: By default, these restrictions only apply to apps that target Android 8.0 (API level 26) or higher. However, users can enable most of these restrictions for any app from the Settings screen, even if the app targets an API level lower than 26.

I'm targeting Below API 26 but i cannot find the settings to enable the restriction in official android emulator.

Where is this setting available?

like image 482
Arnav M. Avatar asked Sep 20 '17 07:09

Arnav M.


1 Answers

The setting to enable the background restriction is available in App Info -> Battery screen.

Not reproducible in emulator yet.

The option is not available when you initially install the application (targeting below API 26) until the app does some background work.

So i was able to produce it by-

  1. Targeting Application at API 25
  2. Create A long running service (around 5 minutes)
  3. Starting the service from onCreate of MainActivity
  4. Send App to background(press back) and leave device on Battery(No power connected)

Within a few minutes, the option will be available to enable the restrictions.

like image 112
Arnav M. Avatar answered Sep 27 '22 17:09

Arnav M.