-1

I m creating an app, where I want to notify my app when phone's location changes in case app is not running in background or in killed state, how will broadcast receiver help me.Please help!

Thanks in advance.

  • You don't have a permission to access the location when your your app is not running (or) background process. – Ashokkumar Adichill Nov 13 '17 at 13:31
  • You should either tun your app on background for doing that refer this link https://stackoverflow.com/questions/47151213/can-i-make-a-background-service-that-runs-at-certain-intervals-of-time-even-afte/47152624#47152624 – Ashokkumar Adichill Nov 13 '17 at 13:32
  • You can look at the answer https://stackoverflow.com/a/24035591/3040889 – ugurcmk Nov 13 '17 at 13:37
  • Hi Ashok, I have asked for permission, and app is getting location when app is in foreground. I was trying to find if there is some intent filter which will invoke my app when location changes using broadcast receivers. Thanks services will also help me with the task but app won't be battery efficient. – Prashant Sethi Nov 14 '17 at 17:32

1 Answers1

0

*if you use googleApiClient and use onLocationChanged(Location location) override method then it automatically called after get new location, and this methods called every some time of seconds so don't depend if your device is really move from previous location so in onLocationChanged() you can do whatever you want of work like send notification to nitifi you but it bad because it will send you maybe every 5 sec or more new notification

*if you don't know how to get location even if app is killed you must create class that extends Service implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener , and write it's methods

hope my answer is helpful , and if you wan't something till me

Mosa
  • 353
  • 2
  • 16