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.

Headless not working Android when app Inactive

See original GitHub issue

Your Environment

  • Plugin version: 2.4.4
  • Platform: Android
  • OS version: 8
  • Device manufacturer / model: One Plus 5
  • React Native version (react-native -v): 57
  • Plugin config
{
            minimumFetchInterval: 15, // <-- minutes (15 is minimum allowed)
            stopOnTerminate: false,   // <-- Android-only,
            startOnBoot: true,         // <-- Android-only
            enableHeadless: true    // <-- Android-only
        }

Expected Behavior

When the app goes into inactive mode, none of the headless tasks run. We force bg-tasks by running adb shell cmd jobscheduler run -f <app-id> 999 An app on android becomes inactive after some time. It can also be forced by running: adb shell am set-inactive <app-id> true

Actual Behavior

The background tasks don’t run. When running adb shell am set-inactive <app-id> false the last task fires.

Steps to Reproduce

See above.

Context

I want to keep running bg-tasks even when android throws the app into inactivity.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
conradjonpcommented, Dec 17, 2018

From the same android documentation of Doze mode:

As soon as the user wakes the device by moving it, turning on the screen, or connecting a charger, the system exits Doze and all apps return to normal activity.

This doesn’t seem to work for Background-Fetch. Once the phone enters doze mode once, the app background fetch never resumes to its intended schedule, even if the phone is plugged in or the screen is turned on. The app needs to be explicitly opened for the background-fetch schedule to resume.

Can we reopen this ticket?

1reaction
christocracycommented, Dec 3, 2018

You can think of the orange bars in the image as background-fetch events. The longer the device sits idle and unplugged from power, the less frequent that fetch events will fire. You might only get 1 per hour after long periods sitting idle.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Restrictions on starting activities from the background
Android 10 (API level 29) and higher place restrictions on when apps can start activities when the app is running in the background....
Read more >
Android. Is WorkManager running when app is closed?
I tested this using OneTimeWorkRequest. However, if the app is running and the worker is not running but is scheduled to run in...
Read more >
React Native, Push Notification & Headaches
Well, it's not true for react native apps and let met tell you why ... To solve this problem, we can turn to...
Read more >
Set up an open, closed, or internal test - Play Console Help
Testing your app allows you to fix any technical or user experience issues with minimal user impact, so you can release the best...
Read more >
How to set up a Headless Chrome Node.js server in Docker
This makes it a stable and efficient way to not only keep running browsers idle, but keep them alive. Puppeteer connection over WebSocket...
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