Giter Club home page Giter Club logo

Comments (66)

zekiegitimcom avatar zekiegitimcom commented on August 23, 2024 5

yes I made a mistake, you do not need to judge immediately.
You're not a robot, are you?

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024 5

You will find the problem in the offending plugin's constructor

This is how it's supposed to be done

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024 3

@mohamedameer020 Your issue is #11. One of your other plugins is misbehaved. You need to find which of your other plugins is executing registrar.activity() before first checking if (registrar.activity() != null). There is no activity in the headless state. That plugin responsible needs to change its code to check activity != null before it attempts to access it.

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024 3

You observe each registerWith method each of your Android plugins.

If registerWith is blindly referencing registrar.activity() without first checking if != null, that plugin needs to guard against registrar.activity() != null.

You can easily browse your installed plugins by opening the Flutter /android app in Android Studio, eg: your_flutter_app/android. Within the /java folder of each plugin will be a file XXXPlugin. Find the method registerWith in each.

In the above screenshot, SharedPreferencesPlugin does not reference registrar.activity() -- it is not an offending plugin.

If any plugin is referencing registrar.activity() without checking != null, add the null check as I've done above. You can edit these files directly in the android Android Studio project as a test. Restart your app each time you edit these files.

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024 3

Huawei are the worst devices on earth for background operations. I own one myself.

See http://dontkillmyapp.com

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024 2

Offending plugins should be notified by offering them a pull-request to fix their issue.

from flutter_background_fetch.

davidevallicella avatar davidevallicella commented on August 23, 2024 2

This risolve problem on P20 lite

Huawei P20, Huawei P20 Lite, Huawei Mate 10
Phone settings > Battery > App launch and then set your app to “Manage manually” and make sure everything is turned on. Also for reliable background processes you may need to uninstall PowerGenie as described above.

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024 1

@davidevallicella Have you tried the /example app in this repo?

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024
  • Ignored issue template
  • No description at all
  • No logs.
  • No config.

from flutter_background_fetch.

robotsrulz avatar robotsrulz commented on August 23, 2024

Doesn't work on Android 9 phone (Huawei Honor 10 Lite). Logs below are from your app published in PlayMarket:

$ /Users/rstepanov/Library/Android/sdk/platform-tools/adb logcat | grep transistor | grep -i job

05-07 23:20:13.210 1435 1435 D JobScheduler: Error executing JobStatus{9391fda #u0a179/-1708771588 com.transistorsoft.flutterbackgroundgeolocationexample/com.transistorsoft.locationmanager.scheduler.ScheduleJobService u=0 s=10179 TIME=-52ms:-52ms READY}
05-07 23:20:31.205 1435 1435 W JobServiceContext: Time-out while trying to bind 9391fda #u0a179/-1708771588 com.transistorsoft.flutterbackgroundgeolocationexample/com.transistorsoft.locationmanager.scheduler.ScheduleJobService, dropping.
05-07 23:20:31.206 1435 1435 E BatteryStatsImpl: Unable to find object for com.transistorsoft.flutterbackgroundgeolocationexample/com.transistorsoft.locationmanager.scheduler.ScheduleJobService in uid 10179 mapsize=0 activeoverflow=null curoverflow=null
05-07 23:22:44.928 1435 1435 D JobScheduler: Error executing JobStatus{8e85b56 #u0a178/999 in.brutalhack.locator/com.transistorsoft.tsbackgroundfetch.FetchJobService u=0 s=10178 TIME=-8ms:+4m59s992ms PERIODIC READY}
05-07 23:23:02.933 1435 1435 W JobServiceContext: Time-out while trying to bind 8e85b56 #u0a178/999 in.brutalhack.locator/com.transistorsoft.tsbackgroundfetch.FetchJobService, dropping.
05-07 23:23:02.933 1435 1435 E BatteryStatsImpl: Unable to find object for in.brutalhack.locator/com.transistorsoft.tsbackgroundfetch.FetchJobService in uid 10178 mapsize=0 activeoverflow=null curoverflow=null
05-07 23:29:59.925 1435 1435 D JobScheduler: Error executing JobStatus{99f2fd8 #u0a179/999 com.transistorsoft.flutterbackgroundgeolocationexample/com.transistorsoft.tsbackgroundfetch.FetchJobService u=0 s=10179 TIME=-1s805ms:+4m58s195ms PERIODIC READY}
05-07 23:30:17.523 1435 1435 W JobServiceContext: Time-out while trying to bind 99f2fd8 #u0a179/999 com.transistorsoft.flutterbackgroundgeolocationexample/com.transistorsoft.tsbackgroundfetch.FetchJobService, dropping.
05-07 23:30:17.524 1435 1435 E BatteryStatsImpl: Unable to find object for com.transistorsoft.flutterbackgroundgeolocationexample/com.transistorsoft.tsbackgroundfetch.FetchJobService in uid 10179 mapsize=0 activeoverflow=null curoverflow=null
05-07 23:35:35.781 3747 3747 I TSLocationManager: "headlessJobService": "com.transistorsoft.flutter.backgroundgeolocation.HeadlessTask",
05-07 23:35:36.021 3747 3747 D TSBackgroundFetch: "jobService": "com.transistorsoft.flutter.backgroundfetch.HeadlessJobService"
05-07 23:36:59.902 1435 1435 D JobScheduler: Error executing JobStatus{6825a19 #u0a179/-1708771588 com.transistorsoft.flutterbackgroundgeolocationexample/com.transistorsoft.locationmanager.scheduler.ScheduleJobService u=0 s=10179 TIME=-12ms:-12ms READY}
05-07 23:37:11.619 4371 4371 I TSLocationManager: "headlessJobService": "com.transistorsoft.flutter.backgroundgeolocation.HeadlessTask",
05-07 23:37:11.860 4371 4371 D TSBackgroundFetch: "jobService": "com.transistorsoft.flutter.backgroundfetch.HeadlessJobService"
05-07 23:37:17.899 1435 1435 W JobServiceContext: Time-out while trying to bind 6825a19 #u0a179/-1708771588 com.transistorsoft.flutterbackgroundgeolocationexample/com.transistorsoft.locationmanager.scheduler.ScheduleJobService, dropping.
05-07 23:37:17.900 1435 1435 E BatteryStatsImpl: Unable to find object for com.transistorsoft.flutterbackgroundgeolocationexample/com.transistorsoft.locationmanager.scheduler.ScheduleJobService in uid 10179 mapsize=0 activeoverflow=null curoverflow=null

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

What is this?

in.brutalhack.locator/com.transistorsoft.tsbackgroundfetch.FetchJobService

from flutter_background_fetch.

robotsrulz avatar robotsrulz commented on August 23, 2024

What is this?

in.brutalhack.locator/com.transistorsoft.tsbackgroundfetch.FetchJobService

A testing app on the same phone which also uses your plugin. It doesn't work too. Both apps give me similar errors.

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

I have a Huawei P20 (ANE-LX3) @ 8.0.0

$ adb shell cmd jobscheduler run -f com.transistorsoft.flutterbackgroundgeolocationexample 999
05-08 08:22:34.744  1254  5981 D JobServiceContext: Scheduling time out for 'com.transistorsoft.tsbackgroundfetch.FetchJobService' jId: 999, in 18 s
05-08 08:22:34.767  1254  1254 D JobServiceContext: handleServiceBound for dbb09cb #u0a148/999 com.transistorsoft.flutterbackgroundgeolocationexample/com.transistorsoft.tsbackgroundfetch.FetchJobService
05-08 08:22:34.767  1254  1254 D JobServiceContext: Scheduling time out for 'com.transistorsoft.tsbackgroundfetch.FetchJobService' jId: 999, in 8 s
05-08 08:22:34.774  1254  5201 D JobServiceContext: Scheduling time out for 'com.transistorsoft.flutter.backgroundfetch.HeadlessJobService' jId: 998, in 18 s
05-08 08:22:34.780  1254  5981 D JobServiceContext: doCallback of : JobStatus{dbb09cb #u0a148/999 com.transistorsoft.flutterbackgroundgeolocationexample/com.transistorsoft.tsbackgroundfetch.FetchJobService u=0 s=10148 TIME=+3h3m29s346ms:+3h8m29s346ms READY} v:VERB_STARTING
05-08 08:22:34.780  1254  5981 D JobServiceContext: Scheduling time out for 'com.transistorsoft.tsbackgroundfetch.FetchJobService' jId: 999, in 600 s
05-08 08:22:34.782  1254  5981 D JobServiceContext: doCallback of : JobStatus{dbb09cb #u0a148/999 com.transistorsoft.flutterbackgroundgeolocationexample/com.transistorsoft.tsbackgroundfetch.FetchJobService u=0 s=10148 TIME=+3h3m29s343ms:+3h8m29s343ms READY} v:VERB_EXECUTING
05-08 08:22:34.797  1254  1254 D JobServiceContext: handleServiceBound for 8d39ffd #u0a148/998 com.transistorsoft.flutterbackgroundgeolocationexample/com.transistorsoft.flutter.backgroundfetch.HeadlessJobService
05-08 08:22:34.797  1254  1254 D JobServiceContext: Scheduling time out for 'com.transistorsoft.flutter.backgroundfetch.HeadlessJobService' jId: 998, in 8 s

05-08 08:22:34.804 10673 10720 I flutter : [BackgroundFetch] HeadlessTask
05-08 08:22:34.805 10673 10720 I flutter : [BackgroundFetch] count: 1250

from flutter_background_fetch.

robotsrulz avatar robotsrulz commented on August 23, 2024

Used the same command to simulate, got the same error:

05-08 15:32:11.733 1435 4186 D JobScheduler: Error executing JobStatus{15bfeac #u0a179/999 com.transistorsoft.flutterbackgroundgeolocationexample/com.transistorsoft.tsbackgroundfetch.FetchJobService u=0 s=10179 TIME=+13m42s670ms:+18m42s670ms PERIODIC READY}
05-08 15:32:29.741 1435 1435 W JobServiceContext: Time-out while trying to bind 15bfeac #u0a179/999 com.transistorsoft.flutterbackgroundgeolocationexample/com.transistorsoft.tsbackgroundfetch.FetchJobService, dropping.
05-08 15:32:29.741 1435 1435 E BatteryStatsImpl: Unable to find object for com.transistorsoft.flutterbackgroundgeolocationexample/com.transistorsoft.tsbackgroundfetch.FetchJobService in uid 10179 mapsize=0 activeoverflow=null curoverflow=null

from flutter_background_fetch.

robotsrulz avatar robotsrulz commented on August 23, 2024

Tested on Samsung Galaxy (Android 8.0.0), it works.

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

Works for me from Play Store version too (previous was my development instance)

05-08 08:45:34.314  8797  8818 I flutter : [BackgroundFetch] received event
05-08 08:45:34.315  8797  8818 I flutter : [BackgroundFetch] count: 1
05-08 08:45:34.326  8797  8797 D TSBackgroundFetch: - finish
05-08 08:45:34.326  8797  8797 D TSBackgroundFetch: - jobFinished

Samsung A510 @ 8.0.0

05-08 08:48:30.268  2088  2088 D TSBackgroundFetch: - Background Fetch event received
05-08 08:48:30.270  2088  2106 I flutter : [BackgroundFetch] received event
05-08 08:48:30.270  2088  2106 I flutter : [BackgroundFetch] count: 873
05-08 08:48:30.280  2088  2088 D TSBackgroundFetch: - finish
05-08 08:48:30.280  2088  2088 D TSBackgroundFetch: - jobFinished

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

@robotsrulz Do you get this error even when the app is booted?

from flutter_background_fetch.

robotsrulz avatar robotsrulz commented on August 23, 2024

No, I don't see this error on app start or phone reboot. However headless doesn't start working on phone reboot. Seems to be something Android 9 specific.

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

However headless doesn't start working on phone reboot

I didn't configure BackgroundFetch with startOnBoot: true in the demo. I should have.

Pixel @ 9.0 (I have a lot of phones)

05-08 10:00:21.326 12555 12555 D TSBackgroundFetch: - Background Fetch event received
05-08 10:00:21.329 12555 12555 D TSBackgroundFetch: - finish
05-08 10:00:21.329 12555 12555 D TSBackgroundFetch: - jobFinished
05-08 10:00:21.348 12555 12555 D TSBackgroundFetch: HeadlessJobService onStartJob
05-08 10:00:21.348 12555 12555 D TSBackgroundFetch: 💀 [HeadlessTask]
05-08 10:00:21.354 12555 12573 I flutter : [BackgroundFetch] HeadlessTask
05-08 10:00:21.357 12555 12573 I flutter : [BackgroundFetch] count: 206
05-08 10:00:21.386 12555 12555 D TSBackgroundFetch: - finish
05-08 10:00:21.386 12555 12555 D TSBackgroundFetch: HeadlessJobService jobFinished

from flutter_background_fetch.

mohamedameer020 avatar mohamedameer020 commented on August 23, 2024

When i terminate my app, background fetch is not working. It show a pop up that " My app has stopped"

05-15 16:03:48.818 24627 24627 D TSBackgroundFetch: - Background Fetch event received
05-15 16:03:48.866 24627 24627 D TSBackgroundFetch: - finish
05-15 16:03:48.866 24627 24627 D TSBackgroundFetch: - jobFinished
05-15 16:03:49.181 24627 24627 D TSBackgroundFetch: HeadlessJobService onStartJob
05-15 16:03:49.181 24627 24627 D TSBackgroundFetch: 💀 [HeadlessTask]

05-15 16:26:01.386 30247 30247 E AndroidRuntime: FATAL EXCEPTION: main
05-15 16:26:01.386 30247 30247 E AndroidRuntime: Process: com.lithos.pos, PID: 30247
05-15 16:26:01.386 30247 30247 E AndroidRuntime: java.lang.RuntimeException: java.lang.IllegalStateException: registrar.activity() must not be null
05-15 16:26:01.386 30247 30247 E AndroidRuntime: at android.app.job.JobService$JobHandler.handleMessage(JobService.java:147)
05-15 16:26:01.386 30247 30247 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:110)
05-15 16:26:01.386 30247 30247 E AndroidRuntime: at android.os.Looper.loop(Looper.java:203)
05-15 16:26:01.386 30247 30247 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6293)
05-15 16:26:01.386 30247 30247 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
05-15 16:26:01.386 30247 30247 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1065)
05-15 16:26:01.386 30247 30247 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:926)
05-15 16:26:01.386 30247 30247 E AndroidRuntime: Caused by: java.lang.IllegalStateException: registrar.activity() must not be null
05-15 16:26:01.386 30247 30247 E AndroidRuntime: at com.apptreesoftware.barcodescan.a$a.a()
05-15 16:26:01.386 30247 30247 E AndroidRuntime: at com.apptreesoftware.barcodescan.a.a()
05-15 16:26:01.386 30247 30247 E AndroidRuntime: at io.flutter.plugins.GeneratedPluginRegistrant.registerWith()
05-15 16:26:01.386 30247 30247 E AndroidRuntime: at com.lithos.pos.Application.registerWith()
05-15 16:26:01.386 30247 30247 E AndroidRuntime: at com.transistorsoft.flutter.backgroundfetch.c.b()
05-15 16:26:01.386 30247 30247 E AndroidRuntime: at com.transistorsoft.flutter.backgroundfetch.c.()
05-15 16:26:01.386 30247 30247 E AndroidRuntime: at com.transistorsoft.flutter.backgroundfetch.HeadlessJobService.onStartJob()
05-15 16:26:01.386 30247 30247 E AndroidRuntime: at android.app.job.JobService$JobHandler.handleMessage(JobService.java:143)
05-15 16:26:01.386 30247 30247 E AndroidRuntime: ... 6 more

it perfectly work in app and minimizing the app.

from flutter_background_fetch.

mohamedameer020 avatar mohamedameer020 commented on August 23, 2024

@mohamedameer020 You issue is #11. One of your other plugins is misbehaved. You need to find which of your other plugins is executing registrar.activity() before first checking if (registrar.activity() != null). There is no activity in the headless state. That plugin responsible needs to change its code to check activity != null before it attempts to access it.

thank you so much.It helped.thank you

from flutter_background_fetch.

sbd2015 avatar sbd2015 commented on August 23, 2024

I found out the offending plugins in my case won't be needed when headless task gets called. So in Application.java, instead of calling all registerWith methods through GeneratedPluginRegistrant class , I left out the offending ones and it seems to work well. I will test further if it has any side effects but what do you think?

from flutter_background_fetch.

HardikkMadaan avatar HardikkMadaan commented on August 23, 2024

@sbd2015. in my case the offending plugin is cloud_firestore.how do I leave it out in the Application.java file?

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

@HardikkMadaan You can't "leave it out". cloud_firestore must be changed here

to this:

public static void registerWith(PluginRegistry.Registrar registrar) {
+    if (registrar.activity() != null) {  // <-- Must check != null before referencing activity
        final MethodChannel channel =
            new MethodChannel(
                registrar.messenger(),
                "plugins.flutter.io/cloud_firestore",
                new StandardMethodCodec(FirestoreMessageCodec.INSTANCE));
        channel.setMethodCallHandler(new CloudFirestorePlugin(channel, registrar.activity()));
+    }
  }

from flutter_background_fetch.

HardikkMadaan avatar HardikkMadaan commented on August 23, 2024

How do we actually find out the offending plugin? In my case it's simply not working. As in I have asked it to display hello when terminated but it's not working. Even tried to force it.

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

You may have to follow the flow of code in registerWith. For example, BackgroundFetch references registrar.activity() within its constructor, which is instantiated by registerWith.

from flutter_background_fetch.

HardikkMadaan avatar HardikkMadaan commented on August 23, 2024

Can we put this code somewhere other than the Main.dart file?
Because I need to fetch location in background and put it to firestore which is happening in the initstate method of some other class. So under the headless config function I have called that initstate function of that class.
And its not working. I have also guarded all plugins against registrar.activity()

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

There is no “state” or “initState” or Flutter UI components in Headless Mode.

You must put your Headless function in main.dart, isolated from your Flutter app.

from flutter_background_fetch.

HardikkMadaan avatar HardikkMadaan commented on August 23, 2024

So you're saying that I cannot call a function of some other class in the headless mode?

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

So you're saying that I cannot call a function of some other class in the headless mode?

No. The background-fetch example in this repo references a 3rd-party plugin SharedPreferences in Headless Mode. This is "calling a function of some other class", no?

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

Are you aware that in Headless mode, main() does not execute. MyApp does not exist.

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

If you have some shared functionality within one of your app components that you need to execute in Headless Mode, migrate those functions into a plain old dart class (eg: util.dart). import util.dart into both your application components and main.dart.

from flutter_background_fetch.

HardikkMadaan avatar HardikkMadaan commented on August 23, 2024

@christocracy This is my code. I tried everything you said . Please see it once
Screenshot from 2019-06-28 02-30-18

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

Why not post your code as text?

What is your issue anyway? Are simulating fetch events and observing the adb logcat as documented in the README?

from flutter_background_fetch.

HardikkMadaan avatar HardikkMadaan commented on August 23, 2024

Yes. I am running them as per the readme. I just want to fetch user Location while the app is closed and give it to Firebase. That is all I want to do!

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

Yes, and what’s the problem? What do the logs say?

from flutter_background_fetch.

HardikkMadaan avatar HardikkMadaan commented on August 23, 2024

It just isn't running and saying the line MissingPluginException...
IIt's just under "this is headless" in the screenshot in the logs section.
Also thanks a lot for understanding that I have less knowledge in flutter and taking out time to reply on each of my comment.

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

Paste the entire contents of your main.dart here (not a screenshot).

from flutter_background_fetch.

HardikkMadaan avatar HardikkMadaan commented on August 23, 2024
import 'dart:collection' as prefix0;
import 'package:flutter/painting.dart';
import 'package:flutter/services.dart';
import 'package:device_id/device_id.dart';
import 'package:firebase_database/firebase_database.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:location/location.dart';
import 'package:whatsupfirebase/email_signIn.dart';
import 'package:whatsupfirebase/main_screen.dart';
import 'package:whatsupfirebase/main_screen.dart';
import 'package:whatsupfirebase/major_features.dart';
import 'package:whatsupfirebase/profile_screen.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:whatsupfirebase/profile_screen2.dart';
import 'package:whatsupfirebase/root.dart';

import 'dart:async';
import 'dart:convert';
import 'package:flutter/services.dart';

import 'package:shared_preferences/shared_preferences.dart';
import 'package:background_fetch/background_fetch.dart';
import 'package:whatsupfirebase/services/location/maps_host.dart';
import 'package:whatsupfirebase/utils/utils.dart';


import 'sign_in.dart';

const EVENTS_KEY = "fetch_events";

/// This "Headless Task" is run when app is terminated.
void backgroundFetchHeadlessTask() async {
  print("this is headless");


  var currentLocation = LocationData;
  final databaseReference = FirebaseDatabase.instance.reference();

  Location location = new Location();
  await location.getLocation().then((LocationData currentLocation){
    databaseReference.child('Hardikk').set({
      'latitude': currentLocation.latitude,
      'longitude': currentLocation.longitude,
    });

  });
 print('done headless');

  /*await MapsHostState().initState();*/


  /*var currentLocation = LocationData;
  final databaseReference = FirebaseDatabase.instance.reference();
  Map<String, double> currentLocationget = new Map();
  StreamSubscription<Map<String, double>> locationSubcription;
  Location location = new Location();
  String _deviceid = 'Unknown';
  String deviceid;



    deviceid = await DeviceId.getID;

    *//*if (deviceid == null) return;*//*

    _deviceid = deviceid;

  currentLocationget['latitude'] = 0.0;
  currentLocationget['longitude'] = 0.0;


  location.onLocationChanged().listen((LocationData currentLocation){
    while(currentLocation == null){
      currentLocationget['latitude'] = 0.0;
      currentLocationget['longitude'] = 0.0;
    }

    currentLocationget['longitude'] = currentLocation.longitude;
    currentLocationget['latitude'] = currentLocation.latitude;

    databaseReference.child(_deviceid).set({
      'latitude': currentLocationget['latitude'],
      'longitude': currentLocationget['longitude'],
    });

  });


*/

  print('[BackgroundFetch] Headless event received.');

  /*SharedPreferences prefs = await SharedPreferences.getInstance();

  // Read fetch_events from SharedPreferences
  List<String> events = [];
  String json = prefs.getString(EVENTS_KEY);
  if (json != null) {
    events = jsonDecode(json).cast<String>();
  }
  // Add new event.
  events.insert(0, new DateTime.now().toString() + ' [Headless]');
  // Persist fetch events in SharedPreferences
  prefs.setString(EVENTS_KEY, jsonEncode(events));*/

  BackgroundFetch.finish();
}

void main(){
  SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]).then((_){
    runApp(new MyApp());

    BackgroundFetch.registerHeadlessTask(backgroundFetchHeadlessTask);
  });

  }

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool _enabled = true;

  int _status = 0;

  List<String> _events = [];

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    // Load persisted fetch events from SharedPreferences
    SharedPreferences prefs = await SharedPreferences.getInstance();
    String json = prefs.getString(EVENTS_KEY);
    if (json != null) {
      setState(() {
        _events = jsonDecode(json).cast<String>();
      });
    }

    // Configure BackgroundFetch.
    BackgroundFetch.configure(BackgroundFetchConfig(
        minimumFetchInterval: 15,
        stopOnTerminate: false,
        enableHeadless: true,
        forceReload: true
    ), _onBackgroundFetch).then((int status) {
      print('this is background');
//      MapsHostState().initState();
      print('[BackgroundFetch] SUCCESS: $status');
      setState(() {
        _status = status;
      });
    }).catchError((e) {
      print('[BackgroundFetch] ERROR: $e');
      setState(() {
        _status = e;
      });
    });

    // Optionally query the current BackgroundFetch status.
    int status = await BackgroundFetch.status;
    setState(() {
      _status = status;
    });

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;
  }

  void _onBackgroundFetch() async {
    SharedPreferences prefs = await SharedPreferences.getInstance();

    // This is the fetch-event callback.
    print('[BackgroundFetch] Event received');
    setState(() {
      _events.insert(0, new DateTime.now().toString());
    });
    // Persist fetch events in SharedPreferences
    prefs.setString(EVENTS_KEY, jsonEncode(_events));

    // IMPORTANT:  You must signal completion of your fetch task or the OS can punish your app
    // for taking too long in the background.
    BackgroundFetch.finish();
  }




  @override
  Widget build(BuildContext context) {





    return new MaterialApp(
      debugShowCheckedModeBanner: false,

      title: "Healthy Being",







      routes: {
        '/': (BuildContext context) => RootPage(),
        '/introscreen': (BuildContext context) =>IntroScreen(),
        '/signin': (BuildContext context) => SignIn(),
        '/signinemail' :(BuildContext context) => SignInEmail()


      },
      theme: ThemeData(
        primaryColor: Color(0xff283593)
      ),

    );
  }
}

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

That flutter location plugin is broken in headless state.

It doesn't even instantiate the plugin instance in the headless state, which is why you see error "No implementation found for method getLocation".

Instead of providing an activity instance to #getFusedLocationProviderClient, it could simply provide the application Context instance via registrar.context(), which does exist in the headless state. That plugin has no need at all for registrar.activity(). It can replace it with registrar.context() and remove the null check on registrar.activity() != null, allowing the plugin to be instantiated in headless mode.

My flutter_background_geolocation will definitely work for you in the headless state. It has a method getCurrentPosition

from flutter_background_fetch.

HardikkMadaan avatar HardikkMadaan commented on August 23, 2024

I tried to use your plugin i.e flutter_background_geolocation but having difficulties implementing it. I'll do the setup part. But can you please implement this function in my code and then send it here? It would be really helpful

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

That location plugin should be providing a Registrar instance to its constructor, not Activity, just a background_fetch does, since registrar has access to both registrar.context() and registrar.activity().

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

Sorry, I haven't the time to fix another one's plugin.

from flutter_background_fetch.

HardikkMadaan avatar HardikkMadaan commented on August 23, 2024

I am not asking you to fix the location plugin sir. I am just asking can you please implement the getCurrentPosition function of your plugin to my main.dart file in the headless config function.
Please?

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

The example usage for BackgroundGeolocation.getCurrentPosition is right there in the API docs

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

If you have an issue with setting up flutter_background_geolocation, post an issue there.

Your issue here is no longer with background_fetch. The fetch mechanism is clearly firing for you.

Your issue now is purely with your application specifics within the fired callback. This issue is closed.

from flutter_background_fetch.

HardikkMadaan avatar HardikkMadaan commented on August 23, 2024

That flutter location plugin is broken in headless state.

It doesn't even instantiate the plugin instance in the headless state, which is why you see error "No implementation found for method getLocation".

Instead of providing an activity instance to #getFusedLocationProviderClient, it could simply provide the application Context instance via registrar.context(), which does exist in the headless state. That plugin has no need at all for registrar.activity(). It can replace it with registrar.context() and remove the null check on registrar.activity() != null, allowing the plugin to be instantiated in headless mode.

My flutter_background_geolocation will definitely work for you in the headless state. It has a method getCurrentPosition

Sir, it would take you only a few seconds to make the changes in the code there . And would solve my problem . Can you please do it ?

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

The issue is not in your code. The issue is with flutter location plugin’s Android code.

It’s not a few seconds.

from flutter_background_fetch.

HardikkMadaan avatar HardikkMadaan commented on August 23, 2024

That flutter location plugin is broken in headless state.

It doesn't even instantiate the plugin instance in the headless state, which is why you see error "No implementation found for method getLocation".

Instead of providing an activity instance to #getFusedLocationProviderClient, it could simply provide the application Context instance via registrar.context(), which does exist in the headless state. That plugin has no need at all for registrar.activity(). It can replace it with registrar.context() and remove the null check on registrar.activity() != null, allowing the plugin to be instantiated in headless mode.

My flutter_background_geolocation will definitely work for you in the headless state. It has a method getCurrentPosition

Sir in this comment you said about providing an instance of Registrar instead of activity . Its just a few steps for you but i am confused and i really need to make it work .

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

Why don’t you post an issue at the Flutter location repo?

from flutter_background_fetch.

HardikkMadaan avatar HardikkMadaan commented on August 23, 2024

Hello Sir. I tried this plugin with you background_geolocation plugin. But its not working with that also. Please see it once

import 'dart:collection' as prefix0;
import 'package:flutter/painting.dart';
import 'package:flutter/services.dart';
import 'package:device_id/device_id.dart';
import 'package:firebase_database/firebase_database.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:whatsupfirebase/email_signIn.dart';
import 'package:whatsupfirebase/main_screen.dart';
import 'package:whatsupfirebase/main_screen.dart';
import 'package:whatsupfirebase/major_features.dart';
import 'package:whatsupfirebase/profile_screen.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:whatsupfirebase/profile_screen2.dart';
import 'package:whatsupfirebase/root.dart';
import 'package:flutter_background_geolocation/flutter_background_geolocation.dart' as bg;
import 'dart:async';
import 'dart:convert';
import 'package:flutter/services.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:background_fetch/background_fetch.dart';
import 'package:whatsupfirebase/services/location/maps_host.dart';
import 'package:whatsupfirebase/utils/utils.dart';
import 'my_app.dart';
import 'sign_in.dart';


const EVENTS_KEY = "fetch_events";

/// This "Headless Task" is run when app is terminated.
void backgroundFetchHeadlessTask() async {
  print('[BackgroundFetch] Headless event received.');
  print("Background Fetch Headless fetch is successful");
  final databaseReference = FirebaseDatabase.instance.reference();

   //Get current-position from BackgroundGeolocation in headless mode.
bg.Location location = await bg.BackgroundGeolocation.getCurrentPosition(samples: 1);
print('Location Milgayi');
  databaseReference.child('Hardikk').set({
    'latitude': location.coords.latitude,
    'longitude': location.coords.longitude,
  });


  BackgroundFetch.finish();
}

void main(){
  SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]).then((_){
    runApp(new MyApp());

    BackgroundFetch.registerHeadlessTask(backgroundFetchHeadlessTask);
  });

}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool _enabled = true;
  int _status = 0;
  List<String> _events = [];

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {


    // Configure BackgroundFetch.
    BackgroundFetch.configure(BackgroundFetchConfig(
        minimumFetchInterval: 15,
        stopOnTerminate: false,
        enableHeadless: true,
        forceReload: false
    ), _onBackgroundFetch).then((int status) {
      print("Background Fetch is successful");

      print('[BackgroundFetch] SUCCESS: $status');
      setState(() {
        _status = status;
      });
    }).catchError((e) {
      print('[BackgroundFetch] ERROR: $e');
      setState(() {
        _status = e;
      });
    });

    // Optionally query the current BackgroundFetch status.
    int status = await BackgroundFetch.status;
    setState(() {
      _status = status;
    });

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;
  }

  void _onBackgroundFetch() async {
    SharedPreferences prefs = await SharedPreferences.getInstance();

    // This is the fetch-event callback.
    print('[BackgroundFetch] Event received');
    setState(() {
      _events.insert(0, new DateTime.now().toString());
    });
    // Persist fetch events in SharedPreferences
    prefs.setString(EVENTS_KEY, jsonEncode(_events));

    // IMPORTANT:  You must signal completion of your fetch task or the OS can punish your app
    // for taking too long in the background.
    BackgroundFetch.finish();
  }





  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      debugShowCheckedModeBanner: false,

      title: "Healthy Being",
      routes: {
        '/': (BuildContext context) => RootPage(),
        '/introscreen': (BuildContext context) =>IntroScreen(),
        '/signin': (BuildContext context) => SignIn(),
        '/signinemail' :(BuildContext context) => SignInEmail()


      },
      theme: ThemeData(
          primaryColor: Color(0xff283593)
      ),

    );
  }
}

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

Define "not working". You've provided no logs at all.

from flutter_background_fetch.

HardikkMadaan avatar HardikkMadaan commented on August 23, 2024

`adb shell cmd jobscheduler run -f com.example.whatsupfirebase 999
adb server version (40) doesn't match this client (39); killing...

  • daemon started successfully
    Could not find job 999 in package com.example.whatsupfirebase / user 0`

This is what i wrote in terminal

And these are the logs
* daemon started successfully --------- beginning of crash --------- beginning of system --------- beginning of main 06-29 23:03:33.337 9422 9422 D TSBackgroundFetch: - start 06-29 23:03:33.623 9422 9451 E flutter : [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: Throw of null. 06-29 23:03:33.623 9422 9451 E flutter : null 06-29 23:03:35.189 9422 9451 E flutter : [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: type 'LocationData' is not a subtype of type 'Type' in type cast 06-29 23:03:35.189 9422 9451 E flutter : #0 _MapsScreenState.initPlatformState (package:whatsupfirebase/services/location/maps_sender.dart:174:56) 06-29 23:03:35.189 9422 9451 E flutter : <asynchronous suspension> 06-29 23:03:35.189 9422 9451 E flutter : #1 _MapsScreenState.initState (package:whatsupfirebase/services/location/maps_sender.dart:86:5) 06-29 23:03:35.189 9422 9451 E flutter : #2 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3846:58) 06-29 23:03:35.189 9422 9451 E flutter : #3 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3717:5) 06-29 23:03:35.189 9422 9451 E flutter : #4 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2961:14) 06-29 23:03:35.189 9422 9451 E flutter : #5 Element.updateChild (package:flutter/src/widgets/framework.dart:2764:12) 06-29 23:03:35.189 9422 9451 E flutter : #6 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3750:16) 06-29 23:03:35.189 9422 9451 E flutter : #7 Element.rebuild (package:flutter/src/widgets/framework.dart:3565:5) 06-29 23:03:35.189 9422 9451 E flutter : #8 StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5) 06-29 23:03:35.189 9422 9451 E flutter : #9 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:15) 06-29 23:03:35.189 9422 9451 E flutter : #10 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14) 06-29 23:03:35.189 9422 9451 E flutter : #11 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:15) 06-29 23:03:35.189 9422 9451 E flutter : #12 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3750:16) 06-29 23:03:35.189 9422 9451 E flutter : #13 Element.rebuild (package:flutter/src/widgets/framework.dart:3565:5) 06-29 23:03:35.189 9422 9451 E flutter : #14 StatelessElement.update (package:flutter/src/widgets/framework.dart:3796:5) 06-29 23:03:35.189 9422 9451 E flutter : #15 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:15) 06-29 23:03:35.189 9422 9451 E flutter : #16 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14) 06-29 23:03:35.189 9422 9451 E flutter : #17 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:15) 06-29 23:03:35.189 9422 9451 E flutter : #18 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14) 06-29 23:03:35.189 9422 9451 E flutter : #19 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:15) 06-29 23:03:35.189 9422 9451 E flutter : #20 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14) 06-29 23:03:35.189 9422 9451 E flutter : #21 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:15) 06-29 23:03:35.189 9422 9451 E flutter : #22 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14) 06-29 23:03:35.189 9422 9451 E flutter : #23 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:15) 06-29 23:03:35.189 9422 9451 E flutter : #24 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3750:16) 06-29 23:03:35.189 9422 9451 E flutter : #25 Element.rebuild (package:flutter/src/widgets/framework.dart:3565:5) 06-29 23:03:35.189 9422 9451 E flutter : #26 StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5) 06-29 23:03:35.189 9422 9451 E flutter : #27 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:15) 06-29 23:03:35.189 9422 9451 E flutter : #28 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3750:16) 06-29 23:03:35.189 9422 9451 E flutter : #29 Element.rebuild (package:flutter/src/widgets/framework.dart:3565:5) 06-29 23:03:35.189 9422 9451 E flutter : #30 StatelessElement.update (package:flutter/src/widgets/framework.dart:3796:5) 06-29 23:03:35.189 9422 9451 E flutter : #31 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:15) 06-29 23:03:35.189 9422 9451 E flutter : #32 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3750:16) 06-29 23:03:35.189 9422 9451 E flutter : #33 Element.rebuild (package:flutter/src/widgets/framework.dart:3565:5) 06-29 23:03:35.189 9422 9451 E flutter : #34 StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5) 06-29 23:03:35.189 9422 9451 E flutter : #35 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:15) 06-29 23:03:35.189 9422 9451 E flutter : #36 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14) 06-29 23:03:35.189 9422 9451 E flutter : #37 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:15) 06-29 23:03:35.189 9422 9451 E flutter : #38 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3750:16) 06-29 23:03:35.189 9422 9451 E flutter : #39 Element.rebuild (package:flutter/src/widgets/framework.dart:3565:5) 06-29 23:03:35.189 9422 9451 E flutter : #40 ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5) 06-29 23:03:35.189 9422 9451 E flutter : #41 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:15) 06-29 23:03:35.189 9422 9451 E flutter : #42 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14) 06-29 23:03:35.189 9422 9451 E flutter : #43 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:15) 06-29 23:03:35.189 9422 9451 E flutter : #44 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3750:16) 06-29 23:03:35.189 9422 9451 E flutter : #45

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

The class LocationData does not come from any of my plugins. It's a class provided by flutterlocation

[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: type 'LocationData' is not 
a subtype of type 'Type' in type cast 06-29 23:03:35.189 9422 9451 E flutter : #0 
_MapsScreenState.initPlatformState 

from flutter_background_fetch.

HardikkMadaan avatar HardikkMadaan commented on August 23, 2024

That is some other problem. It does give an excpetion but has nothing to do with the geolocation plugin not working in headless mode of background_fetch. What to do now?

from flutter_background_fetch.

HardikkMadaan avatar HardikkMadaan commented on August 23, 2024

I think it is because of the license key. I see a toast saying license key not found in meta data something. But I am running it in debug apk mode. So why is it asking me for the key?

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

Forget about the license key Toast. It’s there on purpose to bug you. It’s fully functional in debug builds.

from flutter_background_fetch.

HardikkMadaan avatar HardikkMadaan commented on August 23, 2024

So what do I do?? I have tried everything. Tried location plugin with background_fetch and also background_fetch with background geolocation plugin. Still getting no result

from flutter_background_fetch.

davidevallicella avatar davidevallicella commented on August 23, 2024

I have the same proble but i don't find my bad plugin

CallLogPlugin
DeviceInfoPlugin
SharedPreferencesPlugin

2019-09-24 22:21:28.562 1266-7259/? D/JobScheduler: Error executing JobStatus{f639aee #u0a179/999 it.aladino.nextup.call_sync/com.transistorsoft.tsbackgroundfetch.FetchJobService u=0 s=10179 TIME=+8m54s743ms:+13m54s743ms PERIODIC PERSISTED READY}

from flutter_background_fetch.

davidevallicella avatar davidevallicella commented on August 23, 2024

example

2019-09-24 23:02:39.654 1266-1280/? D/JobScheduler: Error executing JobStatus{e67e614 #u0a19/999 com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample/com.transistorsoft.tsbackgroundfetch.FetchJobService u=0 s=10019 TIME=+38m36s91ms:+43m36s91ms PERIODIC PERSISTED READY}

from flutter_background_fetch.

davidevallicella avatar davidevallicella commented on August 23, 2024

I have the same problem with /example app i have Huawei P20 lite

from flutter_background_fetch.

davidevallicella avatar davidevallicella commented on August 23, 2024

OMG :( thx man ...attach other info for you:

2019-09-24 23:19:43.604 1803-1979/? I/HwRecentsTaskUtils: remove task send broadcast packageName=com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample, userId=0,taskId=2468
2019-09-24 23:19:43.642 1266-17956/? I/ActivityManager: Killing 17803:com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample/u0a19 (adj 900): remove task
2019-09-24 23:19:43.778 1266-1398/? W/InputDispatcher: channel '1346101 com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample/com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
2019-09-24 23:19:43.778 1266-1398/? E/InputDispatcher: channel '1346101 com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample/com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
2019-09-24 23:19:43.788 1266-7094/? I/WindowManager: WIN DEATH: Window{1346101 u0 com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample/com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample.MainActivity}
2019-09-24 23:19:43.788 1266-7094/? V/WindowManager: removeIfPossible: Window{1346101 u0 com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample/com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample.MainActivity}
2019-09-24 23:19:43.788 1266-7094/? W/InputDispatcher: Attempted to unregister already unregistered input channel '1346101 com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample/com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample.MainActivity (server)'
2019-09-24 23:19:43.789 1266-1279/? D/ActivityManager: cleanUpApplicationRecord app: ProcessRecord{e7664f7 17803:com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample/u0a19}, app.bad: false, restarting: false, allowRestart: true
2019-09-24 23:19:43.789 1266-7094/? V/WindowManager: postWindowRemoveCleanupLocked: Window{1346101 u0 com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample/com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample.MainActivity}
2019-09-24 23:19:43.789 1266-7094/? V/WindowManager: Removing Window{1346101 u0 com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample/com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample.MainActivity} from AppWindowToken{6cd4ca0 token=Token{6dc1a3 ActivityRecord{150acd2 u0 com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample/.MainActivity t2468}}}
2019-09-24 23:19:43.797 1266-1279/? V/WindowManager: removeAppToken: AppWindowToken{6cd4ca0 token=Token{6dc1a3 ActivityRecord{150acd2 u0 com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample/.MainActivity t2468}}} delayed=false Callers=com.android.server.wm.DisplayContent.removeAppToken:1086 com.android.server.wm.AppWindowContainerController.removeContainer:315 com.android.server.am.ActivityRecord.removeWindowContainer:1201 com.android.server.am.ActivityStack.removeActivityFromHistoryLocked:4568
2019-09-24 23:22:01.969 1266-7259/? D/JobScheduler: Error executing JobStatus{21685f5 #u0a19/999 com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample/com.transistorsoft.tsbackgroundfetch.FetchJobService u=0 s=10019 TIME=+6m56s463ms:+11m56s463ms PERIODIC PERSISTED READY}

thanks anyway for your time

from flutter_background_fetch.

davidevallicella avatar davidevallicella commented on August 23, 2024

with Nexus 5x work fine :'( ...

work around for my device? exist..??

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

http://dontkillmyapp.con

from flutter_background_fetch.

christocracy avatar christocracy commented on August 23, 2024

Huawei devices are shiny on the outside but complete garbage in the software. You should not be using a Huawei device as your primary development device.

I test regularly on 11 devices. Only the Huawei is junk:

  • Nexus 4 @ 4.4.4
  • Nexus 5 @ 6.0.1
  • Motorola Moto G @ 6.0.0
  • Google Pixel @ 9.0.0
  • Google Pixel 3a @ Q
  • Samsung J @ 6.0.1
  • Samsung A510 @ 8.0.0
  • Huawei P20 Lite (ANE-LX3) @ 8.0.0
  • XIAOMI MI A2 Lite @ 9.0.0
  • Nokia TA-1027 @ 8.0.0
  • OnePlus A5010 @ 8.0.0

Your Nexus 5x will be a better choice for development,

from flutter_background_fetch.

faliscotec avatar faliscotec commented on August 23, 2024

Hi

I've experienced the same issue with the error PERIODIC PERSISTED READY once the ionic app is finished and enable headless is true.

Just in case this is usefull for anyone, in my case, with a Xiaomi 11T and Miui Global 13.0.2, setting autostart permission for the ionic app solved the problem.

from flutter_background_fetch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.