Users in the field are reporting random problems with GPS location in an app.
The app has been using LocationManager for about 12 years with little modification.
I was able to see some unpredictable behavior by testing on Pixel 3 with Android 12.
The behavior includes location being off by half a mile, and not updating regularly unless some other app uses GPS.
Are there some things that are different about location manager in Android 11/12?
If so where are they documented?
The code I have has worked fine since Android 1.5.
I am using it through a library, but decompiling gave me this call:
mLocationManager.requestLocationUpdates("gps", 250, 1, listener);
I changed it to
mLocationManager.requestLocationUpdates("gps", 100, 0, listener);
It worked for a bit and then stopped working again.
The updates don't come in.
Does it need background location even though the documentation says I SHOULDN'T need background location to use location in an activity or foreground service?
If not, what the heck is going on?
Weve seen the same problem #nathanMDT which we logged initially with the SDK we thought was at fault, link below. The problem is Android 12 specifically and a change they made about a month ago to some google map permissions, all the relevant articles can be found in the below post. The devs dropped an update about 3 days ago in this tracker which im hoping will help. First response was "wait till Android 13". As a side note downgrading to Android 11 instantly fixes the frequency updates - not that this helps much.
https://issuetracker.google.com/issues/215186921?pli=1
https://github.com/mapbox/mapbox-unity-sdk/issues/1850
Foreground services still require background location permissions to access location. That's because its non obvious to the user that just because there's a notification there that it's still using GPS. And yes, this was added in Android 11: https://developer.android.com/guide/components/foreground-services#bg-access-restrictions
Related
I have a Flutter app that I'm running a background service on and it works fine even if the user swipes it away. I see that there're a lot of guides targeting native android implementations of this issue but none for Flutter. I'm using flutter_background_service and it works just fine when the app is in the background but not when it is killed. The app needs to be running all the time to listen to accelerometer events and I've tried a lot of packages like workmanager and flutter_foreground_task but they don't work as I'd like. Workmanager can only run every 15 min but that's too long of a duration and foreground_task although it claims it prevents the app from closing, it doesn't actually do that.
I have no Kotlin experience so using Method channels is not viable at the moment for me,I can copy-paste code though :) and I know some Java. Are there any packages that I'm not aware of that can help me to always listen in the background for events and launch or bring the app to the foreground when I want it to?
Using the embedder, Flutter code can be integrated into an existing application as a module, or the code may be the entire content of the application. [Flutter architectural overview]
In other words, your Flutter app running on Android is a regular Android app which has the same constraints like any other Android app.
And as mentionend in the README file of workmanager:
Android will automatically change your frequency to 15 min if you have configured a lower frequency.
This statement can also be be found in the Android documentation:
Note: The minimum repeat interval that can be defined is 15 minutes (same as the JobScheduler API.
So, I'd say that you should respect that constraint for your Android app and not try to come up with a hack which works around it.
I am developing on React Native and using react-native-geolocation-service library to access foreground location only (App is for office and other location checkin purposes)
I recently faced this issue, last week I was still able to upload and release my aab just fine, but this week I can't anymore although I only changed a few UI based on user's feedback.
So basically permission and logic wise there's no change to my app.
I even compared both app's permission list and both are exactly the same:
But then I'm getting this error
even though I have specifically declared here that I'm not accessing background location
This app targetSdkVersion is 28, if that's important, because I heard starting API 28 there are alot of new restrictions on play console.
Have anyone ever encountered this issue?
If this is a problem with the library I'm using could anyone give me any pointers?
Thanks
Okay got it,
I looked into it and found this
https://developer.android.com/training/location/permissions#foreground
so I just added service tag like so
<service
android:name=".ForegroundLocation"
android:foregroundServiceType="location">
</service>
and updated targetSdkVersion to 29 and it worked!
Although still not sure which causes it to work lol
Can anyone explain this to me? Thanks!
I need to detect user dynamics in my application. I started by using GooglePlayServicesClient which till three months ago worked perfectly, Then it stopped working on my HTC one device (although it was still working on three different devices I've checked). I know it is now replaced by GoogleApiClient, so I thought this was my problem, but it keeps not working even after changing to the new API.
The problem is that the intent given to ActivityRecognition.ActivityRecognitionApi.requestActivityUpdates is never called. I used the same implementation as : https://blacode.wordpress.com/2014/12/26/user-activity-recognition-through-new-activityrecognitionapi-in-android-activityrecognitionclient-deprecated/
(And again, this implementation works on three other devices but not on HTC one).
I did some reading online and I saw some similar issues that were solved by updating google play or activating google play location services or disable mock location on the android developers settings. Non worked for me.
Has anyone encountered the same problem or maybe has some idea what can be the cause?
If your onHandleIntent is not being triggered, make sure you have a receiver tag in your manifest (inside the application tag, but outside the activity) :
<service
android:name=".ActivityRecognitionIntentService"
android:exported="false" />
I struggled with this for several hours before finally realizing this was missing. As soon as I added it, everything worked.
Also, if you add an IntentService class through the AndroidStudio submenu for IntentService instead of just adding a plain Java class and setting it up yourself, it will automatically be registered in the manifest. New...->Service->IntentService
Eventually what solved it was resetting the device to manufacturer settings, meaning that the problem was some setting in the device , which I still have no clue to what caused it. If anyone finds an answer I'll be glad to hear about it.
So I downloaded the Sample App for 'Recognizing the User's Current Activity' on the android website http://developer.android.com/training/location/activity-recognition.html
The problem I'm having is that when I press the 'Start Updates' button, then the 'Stop Updates' button, and then the 'Start Updates' button again, the updates don't start again the second time.
I've searched online but couldn't find much material on the topic so yeah, I've also tried debugging and found that the onDisconnected() method call (via the ConnectionCallbacks interface) isn't being called in either of the DetectionRemover.java or DetectionRequester.java files.
If anyone knows why this is happening I'd really like to know why. From what I've gathered it doesn't seem to be anything in the sample code, and I think it might be a problem on the Google Services side.
P.S. I'm using Google Play services rev 16. along with a Samsung galaxy s2 android version 4.1.2
I noticed this same problem running the sample code on my Nexus 4 (Android 4.4.4). I found that if I commented out the following line of code in the ActivityDetectionRemover continueRemoveUpdates() method, it fixed the problem:
mCurrentIntent.cancel();
Sorry, I don't yet have a good explanation as to why canceling the PendingIntent causes this issue.
UPDATE: I also commented out the cancel in the MainActivity onStopUpdates() method:
mDetectionRequester.getRequestPendingIntent().cancel();
Which is effectively doing the same thing as the first line above.
I have a problem with the localization only in Android 4.2.2 devices.
When i use the normal process to get a localization and the fine-location permission is enabled the GPS icon never disapear.
The problem is that the icon appear even the localization is not fetched by the GPS, for example with the getLastKnownLocation (for example with this usefull tip https://code.google.com/p/android-protips-location/source/browse/trunk/src/com/radioactiveyak/location_best_practices/utils/GingerbreadLastLocationFinder.java ) or with the network provider.
The localization process is normal, based on the location best pratices: https://code.google.com/p/android-protips-location/source/browse/trunk/src/com/radioactiveyak/location_best_practices/ project
creates by Reto Meier in this post:
http://android-developers.blogspot.com.es/2011/06/deep-dive-into-location.html
Of course, the locationmanager and listener are stoped and put it to null.
The problem is only for the Android 4.2.2 version.
do you know if this is a Android bug?
Thank you in advance!
I think this describes your problem:
Google Bug report
It looks like a bug to me