Closed bennyt2 closed 4 years ago
I would love to add the new attribute android:foregroundServiceType="location"
to the library but it would break everyone not building with compileSdkVersion 29
.
Try this in the config.xml
:
<widget
+ xmlns:tools="http://schemas.android.com/tools"
>
<platform name="android">
+ <edit-config file="AndroidManifest.xml" mode="merge" target="/manifest">
+ <manifest xmlns:tools="http://schemas.android.com/tools" />
+ </edit-config>
<config-file parent="/manifest/application" target="app/src/main/AndroidManifest.xml">
<meta-data android:name="com.transistorsoft.locationmanager.license_key" android:value="6da948b0a8e4eebd2af03d2defe363bc3d5ca380b4bb846cb8342c6446c69975" />
<meta-data android:name="com.transistorsoft.locationmanager.ENCRYPTION_PASSWORD" android:value="transistorsoft" />
+ <service android:foregroundServiceType="location" android:name="com.transistorsoft.locationmanager.service.TrackingService" tools:node="replace" />
</config-file>
Thanks for your quick reply!
I added those lines and also updated defaultTargetSdkVersion
and defaultCompileSdkVersion
in build.gradle to 29.
Still having the same problem on Android 10. It worked on an Android 9 tablet though.
Is it fair to say that this plugin will not work with the following conditions:
If that's true, then Android 10 users must have their location set to "Always". Just double checking. Thank you.
I've figured out how to do this. It does involve android:foregroundServiceType="location"
, however there's a slight modification required in the plugin's build.gradle
as well. I've just merged the required changes to master
of private repo.
After installing latest master (3.7.0-rc.3
), and ensuring your Cordova app is configured for compileSdkVersion 29
, add the following to your config.xml
(there is no need for the xmlns:tools
/tools:replace
stuff):
<platform name="android">
<config-file parent="/manifest/application" target="app/src/main/AndroidManifest.xml">
<meta-data android:name="com.transistorsoft.locationmanager.license_key" android:value="YOUR_LICENSE_KEY" />
+ <service android:foregroundServiceType="location" android:name="com.transistorsoft.locationmanager.service.TrackingService" />
+ <service android:foregroundServiceType="location" android:name="com.transistorsoft.locationmanager.service.LocationRequestService" />
</config-file>
While your app is in the foreground, execute changePace(true)
then put app in background (or terminate it). In the Sample app, the [ > ]
button execute changePace(true)
. Also, while debugging this, it's best to configure distanceFilter: 0, locationUpdateInterval: 1000, debug: true, LOG_LEVEL_VERBOSE
in order to generate lots of location updates quickly.
@christocracy This works! Thanks for digging into it :)
Device: Google Pixel 3 with Android 10
Use Case: I am building a run tracker app and am trying to mirror permissions in other run tracking apps, which work while location is allowed only when using the app. I'm using this sample app as a guide because we can't get the following scenario working on Android 10.
From what I read on Android permissions, it sounds like the following scenario should work on this app:
However, that doesn't work ((http://tracker.transistorsoft.com/SpikeFalcon?device=15805&end=2020-5-4&start=2020-5-4%2013%3A0). I walked a loop around Overhill Dr and Dunloggin Rd). Almost immediately after the screen turns off, location stops tracking.
Could this be related to foreground service needing to have type "location" in Android 10?
This scenario does work on an Android 8 phone and an ipad.
Has this app been updated to target Android API 29? If not, perhaps that's the issue.