简体   繁体   中英

Activity recognition API not detecting location changes - Android OREO

Issue : Activity recognition API has an intent service which will get the motion activities and will get as part of intent (onHandleIntent). When I changed my app to target android Oreo, the functionality behaves as below

  1. While app is in foreground, app detects activities.
  2. while app in background, it doesn't detect activities

I tried to change the intent service to JobIntentService but not working.

Can anyone help on this?

Thanks in advance.

I faced the same issue. My app worked like charm on previous versions of Android, but no location updates in Oreo.

Found the solution in: https://developer.android.com/about/versions/oreo/background-location-limits.html

I have a service as location listener that runs in the background. In orea background services get only few location updates. It has to be changed to a foreground service. The only thing I had to do is calling startForeground() within onCreate() of the service.

You should check for location retreiving limitations for apps on Oreo when in background or using background services. The answer is to use foreground service or bring app to foreground.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM