开发者

How to check status of GPS in device with android OS?

开发者 https://www.devze.com 2023-03-06 19:35 出处:网络
I have made an android applicaiton (2.2) with GPS functionality.But I want to check GPS status in device is it turn on or turn off.

I have made an android applicaiton (2.2) with GPS functionality.But I want to check GPS status in device is it turn on or turn off. But don't know how to check by programming. Please give me some advice for this question.

Thanks in advance. Edit:

Here is the code for location listener

 lm = (Lo开发者_如何学GocationManager) getSystemService(Context.LOCATION_SERVICE);
        ll = new mylocationlistener();
        lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ll);
        lm.addGpsStatusListener(this);


private class mylocationlistener implements LocationListener {
        @Override
        public void onLocationChanged(Location location) {
            mLastLocationMillis = SystemClock.elapsedRealtime();
            mLastLocation = location;
        }


1) Call addGpsStatusListener() add your listener to it.

2) In the onGpsStatusChanged() callback call the function getGpsStatus()

OR

If you are interested in Sattelite info. you can get it in the LocationListener when requesting for GPS location onStatusChanged()


I think you can find all the answers here: How can I check the current status of the GPS receiver? and here: How do I find out if the GPS of an Android device is enabled

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号