android - onGpsStatusChanged NOT firing for GpsStatus.Listener -
would listen gps availability. followed this. however, ongpsstatuschanged
not fired when disabled/enabled gps. tried on multiple phones. also, looked related stackoverflow qns such this, this , this. met no success. appreciated. thanks!
code snippets:
listener
listener mgpslistener = new gpsstatus.listener() { @override public void ongpsstatuschanged(final int event) { log.d(tag, "---ongpsstatuschanged---"); switch (event) { case gpsstatus.gps_event_started: log.d(tag, "gps_event_started"); break; case gpsstatus.gps_event_first_fix: log.d(tag, "gps_event_first_fix"); break; case gpsstatus.gps_event_stopped: log.d(tag, "gps_event_stopped"); break; case gpsstatus.gps_event_satellite_status: log.d(tag, "gps_event_satellite_status"); break; default: log.d(tag, "something_else"); break; } } };
service
..... @override public int onstartcommand(intent intent, int flags, int startid) { super.onstartcommand(intent, flags, startid); log.d(tag, "onstartcommand"); context ctx = getbasecontext(); log.d(tag, "done, " + ctx); locationmanager locmanager = (locationmanager) ctx.getsystemservice(context.location_service); log.d(tag, "got locmanager"); locmanager.addgpsstatuslistener(mgpslistener); log.d(tag, "added -> locmanager.addgpsstatuslistener(mgpslistener)"); return start_sticky; } .....
could see log statements context
, locationmanager
, etc. nothing ongpsstatuschanged
@ all.
edit1 manifest contains following permissions:
<uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_coarse_location"/> <uses-permission android:name="android.permission.access_fine_location"/>
ok, here finding.
if want ongpsstatuschanged
of gpsstatus.listener
called need not register locationmanager
using addgpsstatuslistener
listen location updates requestlocationupdates
.
as started listening location updates means of requestlocationupdates
of locationmanager
class, started getting gps status changes.
Nice article I was really impressed by seeing this blog, it was very interesting and it is very useful for me.
ReplyDeletemicrosoft dynamics crm training in chennai
microsoft dynamics training in chennai
Angularjs Training in Chennai
CCNA Training in Chennai
Salesforce Training in Chennai
ui ux design course in chennai
It is an informative blog. I would like to know more information. Anyway thanks a lot for sharing this post. Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervour like mine to grasp great deal more around this condition.
ReplyDeleteCyber Security Training Course in Chennai | Certification | Cyber Security Online Training Course | Ethical Hacking Training Course in Chennai | Certification | Ethical Hacking Online Training Course |
CCNA Training Course in Chennai | Certification | CCNA Online Training Course | RPA Robotic Process Automation Training Course in Chennai | Certification | RPA Training Course Chennai | SEO Training in Chennai | Certification | SEO Online Training Course