location - Android O - Old start foreground service still working? -


so, android o, need have service running foreground service if want receive more few location updates per hour.

i noticed old method starting foreground service seem work on o. i.e.

startforeground(notification_id, getnotification()); 

according behaviour changes guide here: https://developer.android.com/preview/behavior-changes.html

"the notificationmanager.startserviceinforeground() method starts foreground service. old way start foreground service no longer works."

though new method works when targeting o, seems old method still seems work on o device whether targeting o or not. missing something?

//edit including example:

the google sample project locationupdatesforegroundservice has working example can see issue first hand. https://github.com/googlesamples/android-play-location/tree/master/locationupdatesforegroundservice

the startforeground method seems work without issue whether targeting , compiling against api level 25 or targeting , compiling against o (as directed here: https://developer.android.com/preview/migration.html#uya)

so, reproduce:

  1. configure app gradle mentioned in previous link
  2. open app
  3. request location updates
  4. close app (either via button or home button)

service running in foreground (shown icon in notification shade). location updates coming through expected (every 10 seconds) on device running o.

this makes me think may missing something.

usually start service broadcast receiver using startservice. saying it's no more possible (or reliable) call startservice because there background limitations, need call startserviceinforeground instead. docs it's not clear when happens because app whitelisted when receives broadcast intent, it's not clear when startservice throws illegalstateexception.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -