Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Doesn't work in real devices #57

Open
Baldur008 opened this issue May 11, 2022 · 6 comments
Open

[BUG] Doesn't work in real devices #57

Baldur008 opened this issue May 11, 2022 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@Baldur008
Copy link

Baldur008 commented May 11, 2022

Describe the bug
It works in emulator but not in a real device

To Reproduce

FlutterBackground.initialize(
        androidConfig: FlutterBackgroundAndroidConfig(
          notificationTitle: "Running in Background",
          notificationImportance: AndroidNotificationImportance.Max,
          notificationText: "Your Location is being updated in background",
        ),
      )
FlutterBackground.enableBackgroundExecution();

Expected behavior
I am calling both initialize and enablebackgroundexecution at the same time. It works on emulator but not in a real device

Smartphone:

  • Emulator: Pixel 4 API 29

Logs:

No Exception/Error Found.

@Baldur008 Baldur008 added the bug Something isn't working label May 11, 2022
@Sesu8642
Copy link

enableBackgroundExecution requires the initialization to be finished. In the emulator, the initialization is presumably fast enough to be finished by chance. You should probably use await:

await FlutterBackground.initialize();
await FlutterBackground.enableBackgroundExecution();

If you need to do it in a non-async function, you can also do the following:

FlutterBackground.initialize().then((success) => FlutterBackground.enableBackgroundExecution());

@omerhertz
Copy link

Same issue for me.
Working fine with emulator.
I see that the await are done, but the app code is not running
I am using:

const androidConfig = FlutterBackgroundAndroidConfig(
    notificationTitle: "App name",
    notificationText: "App is storing your location even when running in background",
    notificationImportance: AndroidNotificationImportance.Max,
    notificationIcon: AndroidResource(name: 'background_icon', defType: 'drawable'),
  );
  await FlutterBackground.initialize(androidConfig: androidConfig);
  await FlutterBackground.enableBackgroundExecution();

@omerhertz
Copy link

The problem was in my real device configuration! I allowed my app to use location all the time, and it started working in the background too!

@JavesonYehudi
Copy link

There's definitely an issue on real devices. You have to initialise the configuration twice in order for it to work.

@innerk
Copy link

innerk commented Sep 30, 2022

same happened to me, on emulator works but on real devices throws

java.lang.RuntimeException: Unable to start service de.julianassmann.flutter_background.IsolateHolderService@8ca558 with Intent { act=START cmp=com.imvaswms.invaswmsdm/de.julianassmann.flutter_background.IsolateHolderService }: java.lang.IllegalArgumentException

@nawbc
Copy link

nawbc commented Feb 26, 2023

Unable to start service Intent { act=START cmp=com.deskbtm.nitmgpt/de.julianassmann.flutter_background.IsolateHolderService } U=0: not found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants