Dani
Dani

Reputation: 15069

How do I get the GPS fix status on android - right now (not using the listener)

I want to know right now if the GPS is turned on and fixed.

I don't want to listen to events - just to get an answer (And if it is fix - get the location).

In all the examples people create a listener and wait for events from the GPS. my call should return immediately.

Anything above level 11 is OK, but if something exists only on level 14 and above I can manage.

Thanks.

Upvotes: 4

Views: 1533

Answers (1)

Sam
Sam

Reputation: 86948

I don't want to listen to events - just to get an answer

You can use getLastKnownLocation() but if this returns null then you must wait for a location update.


To test if the GPS is active use isProviderEnabled().

You should consider using the PASSIVE_PROVIDER as well. This report any location fix whether it's GPS, NETWORK, etc.

Upvotes: 5

Related Questions