Flutter background location service killed by system(mostly Huawei)

138 Views Asked by At

I develop flutter app with background location listener and on most device is all work, but on some device system kill app when app in background(tray/lock screen/another app on foreground). I need result for android part.

I have tried use: flutter_background_service with setForeground/setBackground params, geolocator with notification. I tried combinate this libs, but it's don't have result.

My permissions:

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
    <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />

Services in AndroidManifest:

        <service
            android:name="id.flutter.flutter_background_service.BackgroundService"
            android:foregroundServiceType="location" />

More problems with Huawei. I tried request permission for ignor battery and other battery optinions but nothng help. Someone can help me with this? How I can add my app to system whitelist, or maybe who knows another solution. Thanks.

0

There are 0 best solutions below