Closed EpicVidak closed 3 years ago
Can you please clone this repo and try to run the example on your Android? That should help us rule out whether this is an incompatibility with the device or operating system.
Unfortunately for me, the example app is working as intended. Which means i most likely have some configuration issue that i cannot find. Would be highly appreciated if you could give me a hint as to where to look. As i have previously mentioned, this app was previously a cordova-only project, but since the background-geo(free version) for cordova is no longer maintained, we had to migrate to capacitor after testing and confirming this plugin would serve for our purposes. Im completely stuck and have begun the process of rewriting codebase in new cordova project since we have confirmed it will work. Any advice would be helpful at this point. Thanks in advance :)
I did not see the permissions in your AndroidManifest.xml, are they in there?
<!-- Permissions -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-feature android:name="android.hardware.location.gps" />
</manifest>
Watcher is properly added/removed (going to background/foreground respectively)
What do you mean by this? You are adding/removing watchers when the app changes between background an foreground?
I did not see the permissions in your AndroidManifest.xml, are they in there?
<!-- Permissions --> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-feature android:name="android.hardware.location.gps" /> </manifest>
I just have not included whole AndroidManifest.xml because I assumed it was implied i included all necessary permissions: #
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.enonsolutions.taxi.driver">
<application
android:usesCleartextTraffic="true"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<service
android:name="com.equimaps.capacitor_background_geolocation.BackgroundGeolocationService"
android:enabled="true"
android:exported="true"
android:foregroundServiceType="location" />
<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
android:name="com.enonsolutions.taxi.driver.MainActivity"
android:label="@string/title_activity_main"
android:theme="@style/AppTheme.NoActionBarLaunch"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/custom_url_scheme" />
</intent-filter>
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"></meta-data>
</provider>
</application>
<!-- Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Camera, Photos, input file -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Geolocation API -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-feature android:name="android.hardware.location.gps" />
<!-- Network API -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Navigator.getUserMedia -->
<!-- Video -->
<uses-permission android:name="android.permission.CAMERA" />
<!-- Audio -->
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
</manifest>
Watcher is properly added/removed (going to background/foreground respectively)
What do you mean by this? You are adding/removing watchers when the app changes between background an foreground?
Correct. When app goes in background i add a watcher and when it comes back into foreground i remove it.
edit: i copied AndroidManifest from previous experiments
Watcher is properly added/removed (going to background/foreground respectively)
What do you mean by this? You are adding/removing watchers when the app changes between background an foreground?
I have made a test in which:
Result is that it runs properly as intended. Do you have any idea how to implement so that i can addWatcher from background?
That's interesting, it seems Android does not permit the app to post the notification once the app is backgrounded. Can you please explain your use case? I'd like to understand why you only need to listen for location updates in the background.
Only thing i have found is in logcat from Android Studio:
I have tried adding :
<uses-permission android:name="com.sec.android.provider.badge.permission.READ"/>
<uses-permission android:name="com.sec.android.provider.badge.permission.WRITE"/>
didn't notice any changes to plugin behaviour.MainActivity.java:
AndroidManifest.xml:
Implementation: