Search code examples
androidxamarinlocationandroid-broadcastandroid-geofence

Unable to start Service after App startup


Hello all i want location updates when my app is triggered first and after even it is killed i want my service to run i tried broadcast receiver for this purpose but it run on phone reboot Can anybody guide me to the right direction? Thanks


Solution

  • depending on the layout of your code, I believe it might be as easy as making the app perform the location update request on onResume while leaving onPause blank to test if it works for what you want. At least if I understood you correctly, that's what worked for me but it might drain your battery if you are using some power demanding location provider like GPS. And about your service to survive reboot I'm not really acquainted on that topic but from a quick read, indeed using broadcast receiver and listening for BOOT_COMPLETED to set off an intent.setAction declared after onCreate on your MainActivity should do it, but haven't tested that myself yet. Anyhow, it would be best if you can post the code you're working with so that others can see exactly what you have so far and be more helpful.

    Hope it helps