ekasetiawans / flutter_background_service

263 stars 183 forks source link

AndroidConfiguration autoStart:false #338

Open joharputr opened 1 year ago

joharputr commented 1 year ago

auto start false not working ,

I set auto start: false but still starting service

pmatatias commented 11 months ago

I assume you copy the code of initializeService method from the example.

you need to remove the service.startService(); at the and of the method. Because this command will start the service. even when you set autoStart:false , the onstart method will invoke after that command.

Future<void> initializeService() async {
  final service = FlutterBackgroundService();
   ....
   ....
   ....
  await service.configure(
    androidConfiguration: AndroidConfiguration(
      autoStart: false,
      // others config
    ),
    iosConfiguration: IosConfiguration(
      // auto start service
      autoStart: false,
      // others config
    ),
  );

  //  service.startService();  <<<<== Remove this line
}
zzzh commented 6 months ago

There's no startService() now(version 5.05), so, how to start it?