rekabhq / background_locator

A Flutter plugin for updating location in background.
MIT License
287 stars 321 forks source link

Restart service on device reboot is not working on android 12 #345

Open kotran88 opened 1 year ago

kotran88 commented 1 year ago

it works very well on background and even app is killed. but when I reboot android phone then it cause error saying backgound_locator_example is keep shut down.

무제

my android manifext.xml is as below

`<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="rekab.app.background_locator_example"

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

<!-- io.flutter.app.FlutterApplication is an android.app.Application that
     calls FlutterMain.startInitialization(this); in its onCreate method.
     In most cases you can leave this as-is, but you if you want to provide
     additional functionality it is fine to subclass or reimplement
     FlutterApplication and put your custom class here. -->
<application
    android:label="background_locator_example"
    android:name="${applicationName}"
    android:requestLegacyExternalStorage="true"
    android:icon="@mipmap/ic_launcher"
    android:allowBackup="false"
    >
    <activity
        android:name=".MainActivity"
        android:exported="true"
        android:launchMode="singleTop"
        android:theme="@style/LaunchTheme"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
        android:hardwareAccelerated="true"
        android:windowSoftInputMode="adjustResize"
        >
        <meta-data
            android:name="io.flutter.embedding.android.SplashScreenDrawable"
            android:resource="@drawable/launch_background" />
        <meta-data
            android:name="io.flutter.embedding.android.NormalTheme"
            android:resource="@style/NormalTheme"
            />
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <receiver android:name="rekab.app.background_locator.BootBroadcastReceiver"
    android:exported="false"
        android:enabled="true">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED"/>
        </intent-filter>
    </receiver>
    <service
        android:name="rekab.app.background_locator.IsolateHolderService"
        android:permission="android.permission.FOREGROUND_SERVICE"
        android:exported="false"
        android:foregroundServiceType = "location"
        />

    <meta-data android:name="flutterEmbedding" android:value="2"/>

</application>

`